@@ -5,12 +5,11 @@ package p
5
5
6
6
import (
7
7
"context"
8
- "errors"
9
8
"time"
10
9
11
10
ginkgo "github.com/onsi/ginkgo/v2"
12
11
13
- "github.com/onsi/gomega "
12
+ "github.com/stretchr/testify/require "
14
13
15
14
"github.com/ava-labs/avalanchego/api/info"
16
15
"github.com/ava-labs/avalanchego/ids"
@@ -33,6 +32,8 @@ import (
33
32
// - Checks the expected value of the funding address
34
33
35
34
var _ = e2e .DescribePChain ("[Workflow]" , func () {
35
+ require := require .New (ginkgo .GinkgoT ())
36
+
36
37
ginkgo .It ("P-chain main operations" ,
37
38
// use this for filtering tests by labels
38
39
// ref. https://onsi.github.io/ginkgo/#spec-labels
@@ -55,7 +56,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
55
56
ctx , cancel := context .WithTimeout (context .Background (), e2e .DefaultWalletCreationTimeout )
56
57
minValStake , minDelStake , err := pChainClient .GetMinStake (ctx , constants .PlatformChainID )
57
58
cancel ()
58
- gomega . Expect (err ). Should ( gomega . BeNil () )
59
+ require . NoError (err )
59
60
tests .Outf ("{{green}} minimal validator stake: %d {{/}}\n " , minValStake )
60
61
tests .Outf ("{{green}} minimal delegator stake: %d {{/}}\n " , minDelStake )
61
62
@@ -64,7 +65,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
64
65
ctx , cancel = context .WithTimeout (context .Background (), e2e .DefaultWalletCreationTimeout )
65
66
fees , err := infoClient .GetTxFee (ctx )
66
67
cancel ()
67
- gomega . Expect (err ). Should ( gomega . BeNil () )
68
+ require . NoError (err )
68
69
txFees := uint64 (fees .TxFee )
69
70
tests .Outf ("{{green}} txFee: %d {{/}}\n " , txFees )
70
71
@@ -77,7 +78,8 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
77
78
pBalances , err := pWallet .Builder ().GetBalance ()
78
79
pBalance := pBalances [avaxAssetID ]
79
80
minBalance := minValStake + txFees + minDelStake + txFees + toTransfer + txFees
80
- gomega .Expect (pBalance , err ).To (gomega .BeNumerically (">=" , minBalance ))
81
+ require .NoError (err )
82
+ require .GreaterOrEqual (pBalance , minBalance )
81
83
})
82
84
// create validator data
83
85
validatorStartTimeDiff := 30 * time .Second
@@ -86,7 +88,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
86
88
// Use a random node ID to ensure that repeated test runs
87
89
// will succeed against a persistent network.
88
90
validatorID , err := ids .ToNodeID (utils .RandomBytes (ids .NodeIDLen ))
89
- gomega . Expect (err ). Should ( gomega . BeNil () )
91
+ require . NoError (err )
90
92
91
93
vdr := & txs.Validator {
92
94
NodeID : validatorID ,
@@ -109,7 +111,7 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
109
111
common .WithContext (ctx ),
110
112
)
111
113
cancel ()
112
- gomega . Expect (err ). Should ( gomega . BeNil () )
114
+ require . NoError (err )
113
115
})
114
116
115
117
ginkgo .By ("issue add delegator tx" , func () {
@@ -120,17 +122,17 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
120
122
common .WithContext (ctx ),
121
123
)
122
124
cancel ()
123
- gomega . Expect (err ). Should ( gomega . BeNil () )
125
+ require . NoError (err )
124
126
})
125
127
126
128
// retrieve initial balances
127
129
pBalances , err := pWallet .Builder ().GetBalance ()
128
- gomega . Expect (err ). Should ( gomega . BeNil () )
130
+ require . NoError (err )
129
131
pStartBalance := pBalances [avaxAssetID ]
130
132
tests .Outf ("{{blue}} P-chain balance before P->X export: %d {{/}}\n " , pStartBalance )
131
133
132
134
xBalances , err := xWallet .Builder ().GetFTBalance ()
133
- gomega . Expect (err ). Should ( gomega . BeNil () )
135
+ require . NoError (err )
134
136
xStartBalance := xBalances [avaxAssetID ]
135
137
tests .Outf ("{{blue}} X-chain balance before P->X export: %d {{/}}\n " , xStartBalance )
136
138
@@ -160,22 +162,22 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
160
162
common .WithContext (ctx ),
161
163
)
162
164
cancel ()
163
- gomega . Expect (err ). Should ( gomega . BeNil () )
165
+ require . NoError (err )
164
166
})
165
167
166
168
// check balances post export
167
169
pBalances , err = pWallet .Builder ().GetBalance ()
168
- gomega . Expect (err ). Should ( gomega . BeNil () )
170
+ require . NoError (err )
169
171
pPreImportBalance := pBalances [avaxAssetID ]
170
172
tests .Outf ("{{blue}} P-chain balance after P->X export: %d {{/}}\n " , pPreImportBalance )
171
173
172
174
xBalances , err = xWallet .Builder ().GetFTBalance ()
173
- gomega . Expect (err ). Should ( gomega . BeNil () )
175
+ require . NoError (err )
174
176
xPreImportBalance := xBalances [avaxAssetID ]
175
177
tests .Outf ("{{blue}} X-chain balance after P->X export: %d {{/}}\n " , xPreImportBalance )
176
178
177
- gomega . Expect ( xPreImportBalance ). To ( gomega . Equal (xStartBalance ) ) // import not performed yet
178
- gomega . Expect ( pPreImportBalance ). To ( gomega . Equal (pStartBalance - toTransfer - txFees ) )
179
+ require . Equal (xPreImportBalance , xStartBalance ) // import not performed yet
180
+ require . Equal (pPreImportBalance , pStartBalance - toTransfer - txFees )
179
181
180
182
ginkgo .By ("import avax from P into X chain" , func () {
181
183
ctx , cancel := context .WithTimeout (context .Background (), e2e .DefaultConfirmTxTimeout )
@@ -185,21 +187,21 @@ var _ = e2e.DescribePChain("[Workflow]", func() {
185
187
common .WithContext (ctx ),
186
188
)
187
189
cancel ()
188
- gomega . Expect (err ). Should ( gomega . BeNil (), "is context.DeadlineExceeded: %v" , errors . Is ( err , context . DeadlineExceeded ) )
190
+ require . NoError (err )
189
191
})
190
192
191
193
// check balances post import
192
194
pBalances , err = pWallet .Builder ().GetBalance ()
193
- gomega . Expect (err ). Should ( gomega . BeNil () )
195
+ require . NoError (err )
194
196
pFinalBalance := pBalances [avaxAssetID ]
195
197
tests .Outf ("{{blue}} P-chain balance after P->X import: %d {{/}}\n " , pFinalBalance )
196
198
197
199
xBalances , err = xWallet .Builder ().GetFTBalance ()
198
- gomega . Expect (err ). Should ( gomega . BeNil () )
200
+ require . NoError (err )
199
201
xFinalBalance := xBalances [avaxAssetID ]
200
202
tests .Outf ("{{blue}} X-chain balance after P->X import: %d {{/}}\n " , xFinalBalance )
201
203
202
- gomega . Expect ( xFinalBalance ). To ( gomega . Equal (xPreImportBalance + toTransfer - txFees ) ) // import not performed yet
203
- gomega . Expect ( pFinalBalance ). To ( gomega . Equal (pPreImportBalance ) )
204
+ require . Equal (xFinalBalance , xPreImportBalance + toTransfer - txFees ) // import not performed yet
205
+ require . Equal (pFinalBalance , pPreImportBalance )
204
206
})
205
207
})
0 commit comments