forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 0
/
suites.go
138 lines (116 loc) · 3.7 KB
/
suites.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
// Implements tests for the blueberry network upgrade.
package blueberry
import (
"context"
"github.com/onsi/gomega"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/dim4egster/qmallgo/genesis"
"github.com/dim4egster/qmallgo/ids"
"github.com/dim4egster/qmallgo/tests"
"github.com/dim4egster/qmallgo/tests/e2e"
"github.com/dim4egster/qmallgo/utils/constants"
"github.com/dim4egster/qmallgo/utils/units"
"github.com/dim4egster/qmallgo/vms/components/avax"
"github.com/dim4egster/qmallgo/vms/components/verify"
"github.com/dim4egster/qmallgo/vms/secp256k1fx"
"github.com/dim4egster/qmallgo/wallet/subnet/primary"
)
var _ = e2e.DescribeLocal("[Blueberry]", func() {
ginkgo.It("can send custom assets X->P and P->X", func() {
if e2e.GetEnableWhitelistTxTests() {
ginkgo.Skip("whitelist vtx tests are enabled; skipping")
}
uris := e2e.GetURIs()
gomega.Expect(uris).ShouldNot(gomega.BeEmpty())
kc := secp256k1fx.NewKeychain(genesis.EWOQKey)
var wallet primary.Wallet
ginkgo.By("initialize wallet", func() {
walletURI := uris[0]
// 5-second is enough to fetch initial UTXOs for test cluster in "primary.NewWallet"
ctx, cancel := context.WithTimeout(context.Background(), e2e.DefaultWalletCreationTimeout)
var err error
wallet, err = primary.NewWalletFromURI(ctx, walletURI, kc)
cancel()
gomega.Expect(err).Should(gomega.BeNil())
tests.Outf("{{green}}created wallet{{/}}\n")
})
// Get the P-chain and the X-chain wallets
pWallet := wallet.P()
xWallet := wallet.X()
// Pull out useful constants to use when issuing transactions.
xChainID := xWallet.BlockchainID()
owner := &secp256k1fx.OutputOwners{
Threshold: 1,
Addrs: []ids.ShortID{
genesis.EWOQKey.PublicKey().Address(),
},
}
var assetID ids.ID
ginkgo.By("create new X-chain asset", func() {
var err error
assetID, err = xWallet.IssueCreateAssetTx(
"RnM",
"RNM",
9,
map[uint32][]verify.State{
0: {
&secp256k1fx.TransferOutput{
Amt: 100 * units.Schmeckle,
OutputOwners: *owner,
},
},
},
)
gomega.Expect(err).Should(gomega.BeNil())
tests.Outf("{{green}}created new X-chain asset{{/}}: %s\n", assetID)
})
ginkgo.By("export new X-chain asset to P-chain", func() {
txID, err := xWallet.IssueExportTx(
constants.PlatformChainID,
[]*avax.TransferableOutput{
{
Asset: avax.Asset{
ID: assetID,
},
Out: &secp256k1fx.TransferOutput{
Amt: 100 * units.Schmeckle,
OutputOwners: *owner,
},
},
},
)
gomega.Expect(err).Should(gomega.BeNil())
tests.Outf("{{green}}issued X-chain export{{/}}: %s\n", txID)
})
ginkgo.By("import new asset from X-chain on the P-chain", func() {
txID, err := pWallet.IssueImportTx(xChainID, owner)
gomega.Expect(err).Should(gomega.BeNil())
tests.Outf("{{green}}issued P-chain import{{/}}: %s\n", txID)
})
ginkgo.By("export asset from P-chain to the X-chain", func() {
txID, err := pWallet.IssueExportTx(
xChainID,
[]*avax.TransferableOutput{
{
Asset: avax.Asset{
ID: assetID,
},
Out: &secp256k1fx.TransferOutput{
Amt: 100 * units.Schmeckle,
OutputOwners: *owner,
},
},
},
)
gomega.Expect(err).Should(gomega.BeNil())
tests.Outf("{{green}}issued P-chain export{{/}}: %s\n", txID)
})
ginkgo.By("import asset from P-chain on the X-chain", func() {
txID, err := xWallet.IssueImportTx(constants.PlatformChainID, owner)
gomega.Expect(err).Should(gomega.BeNil())
tests.Outf("{{green}}issued X-chain import{{/}}: %s\n", txID)
})
})
})