-
Notifications
You must be signed in to change notification settings - Fork 122
/
polkadot_chain_test.go
83 lines (71 loc) · 2.44 KB
/
polkadot_chain_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package polkadot_test
import (
"context"
"testing"
"github.com/stretchr/testify/require"
"go.uber.org/zap/zaptest"
"github.com/strangelove-ventures/interchaintest/v8"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
)
func TestWalletMethods(t *testing.T) {
ctx := context.Background()
nv := 5
nf := 3
chains, err := interchaintest.NewBuiltinChainFactory(zaptest.NewLogger(t), []*interchaintest.ChainSpec{
{
ChainConfig: ibc.ChainConfig{
Type: "polkadot",
Name: "composable",
ChainID: "rococo-local",
Images: []ibc.DockerImage{
{
Repository: "seunlanlege/centauri-polkadot",
Version: "v0.9.27",
UIDGID: "1025:1025",
},
{
Repository: "seunlanlege/centauri-parachain",
Version: "v0.9.27",
UIDGID: "1025:1025",
},
},
Bin: "polkadot",
Bech32Prefix: "composable",
Denom: "uDOT",
GasPrices: "",
GasAdjustment: 0,
TrustingPeriod: "",
CoinType: "354",
},
NumValidators: &nv,
NumFullNodes: &nf,
},
},
).Chains(t.Name())
require.NoError(t, err, "failed to get polkadot chain")
require.Len(t, chains, 1)
chain := chains[0]
// BuildRelayerWallet test
relayKeyName := "relayerWallet"
relayWallet, err := chain.BuildRelayerWallet(ctx, relayKeyName)
require.NoError(t, err, "Error building wallet")
address, err := chain.GetAddress(ctx, relayKeyName)
require.NoError(t, err, "Error getting relay address")
require.Equal(t, relayWallet.FormattedAddress(), string(address), "Relay addresses not equal")
// BuildWallet test
userKeyName := "userWallet"
userWallet, err := chain.BuildRelayerWallet(ctx, userKeyName)
require.NoError(t, err, "Error building wallet")
address, err = chain.GetAddress(ctx, userKeyName)
require.NoError(t, err, "Error getting user address")
require.Equal(t, userWallet.FormattedAddress(), string(address), "User addresses not equal")
// RecoverKey test
recoverKeyName := "recoverWallet"
err = chain.RecoverKey(ctx, recoverKeyName, userWallet.Mnemonic())
require.NoError(t, err, "Error on RecoverKey")
userAddress, err := chain.GetAddress(ctx, userKeyName)
require.NoError(t, err, "Error getting user address for recover comparison")
recoverAddress, err := chain.GetAddress(ctx, recoverKeyName)
require.NoError(t, err, "Error getting recover address for recover comparison")
require.Equal(t, userAddress, recoverAddress, "User and recover addresses not equal")
}