starter_test.go 748 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
package sign

import (
	"testing"

	"dfss/dfssp/contract"

	"github.com/bmizerany/assert"
)

func TestFindId(t *testing.T) {
	mail := "signer2@foo.foo"

14
15
16
	s1 := contract.SignerJSON{Email: "signer1@foo.foo"}
	s2 := contract.SignerJSON{Email: mail}
	s3 := contract.SignerJSON{Email: "signer3@foo.foo"}
17
18
19
20
21
22
23
24
25
26
27
28
29

	contract := &contract.JSON{
		Signers: []contract.SignerJSON{s1, s2, s3},
	}

	sequence := []uint32{0, 1, 2, 0, 1, 2, 0, 1, 2}

	sm := &SignatureManager{
		contract: contract,
		sequence: sequence,
		mail:     mail,
	}

30
	id, err := sm.FindID()
31
32
33
34
	assert.Equal(t, err, nil)
	assert.Equal(t, id, uint32(1))

	sm.mail = ""
35
	id, err = sm.FindID()
36
37
	assert.Equal(t, err.Error(), "Mail couldn't be found amongst signers")
	assert.Equal(t, id, uint32(0))
38
}