forked from cosmos/cosmos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
context_test.go
40 lines (30 loc) · 1015 Bytes
/
context_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package auth
import (
"testing"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tendermint/libs/log"
sdk "github.com/cosmos/cosmos-sdk/types"
)
func TestContextWithSigners(t *testing.T) {
ms, _, _ := setupMultiStore()
ctx := sdk.NewContext(ms, abci.Header{ChainID: "mychainid"}, false, log.NewNopLogger())
_, _, addr1 := keyPubAddr()
_, _, addr2 := keyPubAddr()
acc1 := NewBaseAccountWithAddress(addr1)
acc1.SetSequence(7132)
acc2 := NewBaseAccountWithAddress(addr2)
acc2.SetSequence(8821)
// new ctx has no signers
signers := GetSigners(ctx)
require.Equal(t, 0, len(signers))
ctx2 := WithSigners(ctx, []Account{&acc1, &acc2})
// original context is unchanged
signers = GetSigners(ctx)
require.Equal(t, 0, len(signers))
// new context has signers
signers = GetSigners(ctx2)
require.Equal(t, 2, len(signers))
require.Equal(t, acc1, *(signers[0].(*BaseAccount)))
require.Equal(t, acc2, *(signers[1].(*BaseAccount)))
}