starter_test.go 754 Bytes
Newer Older
1 2 3 4 5 6
package sign

import (
	"testing"

	"dfss/dfssp/contract"
7
	"github.com/stretchr/testify/assert"
8 9 10 11 12
)

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

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

	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,
	}

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

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