Skip to content

Commit 69dd411

Browse files
committed
Revert commended lines
1 parent 7965c7e commit 69dd411

File tree

1 file changed

+53
-51
lines changed

1 file changed

+53
-51
lines changed

nil/tests/multitoken/multitoken_test.go

+53-51
Original file line numberDiff line numberDiff line change
@@ -208,38 +208,38 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
208208
s.Equal(types.NewValueFromUint64(100), tokens[*token1.id])
209209
})
210210
})
211-
//return
212-
213-
//s.Run("Send from Wallet1 to Wallet2 via asyncCall", func() {
214-
// receipt := s.SendTransactionViaSmartAccountNoCheck(
215-
// s.smartAccountAddress1,
216-
// s.smartAccountAddress2,
217-
// execution.MainPrivateKey,
218-
// nil,
219-
// types.NewFeePackFromGas(500_000),
220-
// types.Value{},
221-
// []types.TokenBalance{{Token: *token1.id, Balance: types.NewValueFromUint64(50)}})
222-
// s.Require().True(receipt.Success)
223-
// s.Require().True(receipt.OutReceipts[0].Success)
224-
//
225-
// s.Run("Check token is transferred", func() {
226-
// tokens, err := s.Client.GetTokens(s.Context, s.smartAccountAddress1, "latest")
227-
// s.Require().NoError(err)
228-
// s.Require().Len(tokens, 1)
229-
// s.Equal(types.NewValueFromUint64(200), tokens[*token1.id])
230-
//
231-
// tokens, err = s.Client.GetTokens(s.Context, s.smartAccountAddress2, "latest")
232-
// s.Require().NoError(err)
233-
// s.Require().Len(tokens, 1)
234-
// s.Equal(types.NewValueFromUint64(150), tokens[*token1.id])
235-
//
236-
// // Cross-shard `Nil.tokenBalance` should fail
237-
// s.Require().NotEqual(s.testAddress1_0.ShardId(), s.smartAccountAddress2.ShardId())
238-
// data := s.AbiPack(s.abiTest, "checkTokenBalance", s.smartAccountAddress2, token1.id, big.NewInt(150))
239-
// receipt = s.SendExternalTransactionNoCheck(data, s.testAddress1_0)
240-
// s.Require().False(receipt.Success)
241-
// })
242-
//})
211+
return
212+
213+
s.Run("Send from Wallet1 to Wallet2 via asyncCall", func() {
214+
receipt := s.SendTransactionViaSmartAccountNoCheck(
215+
s.smartAccountAddress1,
216+
s.smartAccountAddress2,
217+
execution.MainPrivateKey,
218+
nil,
219+
types.NewFeePackFromGas(500_000),
220+
types.Value{},
221+
[]types.TokenBalance{{Token: *token1.id, Balance: types.NewValueFromUint64(50)}})
222+
s.Require().True(receipt.Success)
223+
s.Require().True(receipt.OutReceipts[0].Success)
224+
225+
s.Run("Check token is transferred", func() {
226+
tokens, err := s.Client.GetTokens(s.Context, s.smartAccountAddress1, "latest")
227+
s.Require().NoError(err)
228+
s.Require().Len(tokens, 1)
229+
s.Equal(types.NewValueFromUint64(200), tokens[*token1.id])
230+
231+
tokens, err = s.Client.GetTokens(s.Context, s.smartAccountAddress2, "latest")
232+
s.Require().NoError(err)
233+
s.Require().Len(tokens, 1)
234+
s.Equal(types.NewValueFromUint64(150), tokens[*token1.id])
235+
236+
// Cross-shard `Nil.tokenBalance` should fail
237+
s.Require().NotEqual(s.testAddress1_0.ShardId(), s.smartAccountAddress2.ShardId())
238+
data := s.AbiPack(s.abiTest, "checkTokenBalance", s.smartAccountAddress2, token1.id, big.NewInt(150))
239+
receipt = s.SendExternalTransactionNoCheck(data, s.testAddress1_0)
240+
s.Require().False(receipt.Success)
241+
})
242+
})
243243

244244
s.Run("TestDeployWithToken", func() {
245245
tokens := []types.TokenBalance{{Token: *token1.id, Balance: types.NewValueFromUint64(10)}}
@@ -346,6 +346,8 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
346346
tokenTest1 := CreateTokenId(&s.testAddress1_0)
347347
tokenTest2 := CreateTokenId(&s.testAddress1_1)
348348
tokenToSend := types.NewValueFromUint64(5000)
349+
tokenInitial := types.NewValueFromUint64(1_000_000)
350+
defaultFee := types.NewFeePackFromGas(100_000)
349351

350352
s.Run("Create tokens for test addresses", func() {
351353
s.createTokenForTestContract(tokenTest1, types.NewValueFromUint64(1_000_000), "testToken1")
@@ -359,18 +361,18 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
359361
s.Require().NoError(err)
360362

361363
hash, err := s.Client.SendExternalTransaction(
362-
s.Context, data, s.testAddress1_0, nil, types.NewFeePackFromGas(100_000))
364+
s.Context, data, s.testAddress1_0, nil, defaultFee)
363365
s.Require().NoError(err)
364366
receipt := s.WaitForReceipt(hash)
365367
s.Require().True(receipt.Success)
366368

367369
s.Run("Check token is debited from testAddress1_0", func() {
368370
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_0, "latest")
369371
s.Require().NoError(err)
370-
s.Equal(types.NewValueFromUint64(1_000_000).Sub(tokenToSend), tokens[*tokenTest1.id])
372+
s.Equal(tokenInitial.Sub(tokenToSend), tokens[*tokenTest1.id])
371373

372374
// Check balance via `Nil.tokenBalance` Solidity method
373-
newBalance := big.NewInt(1_000_000)
375+
newBalance := tokenInitial.ToBig()
374376
newBalance.Sub(newBalance, tokenToSend.ToBig())
375377
data, err := s.abiTest.Pack(
376378
"checkTokenBalance", s.testAddress1_0, tokenTest1.id, newBalance)
@@ -405,7 +407,7 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
405407
s.Run("Check token of testAddress1_0", func() {
406408
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_0, "latest")
407409
s.Require().NoError(err)
408-
s.Equal(types.NewValueFromUint64(1_000_000-5000), tokens[*tokenTest1.id])
410+
s.Equal(tokenInitial.Sub(tokenToSend), tokens[*tokenTest1.id])
409411
})
410412

411413
s.Run("Check token of testAddress1_1", func() {
@@ -421,7 +423,7 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
421423
s.Require().NoError(err)
422424

423425
hash, err := s.Client.SendExternalTransaction(
424-
s.Context, data, s.testAddress1_0, nil, types.NewFeePackFromGas(100_000))
426+
s.Context, data, s.testAddress1_0, nil, defaultFee)
425427
s.Require().NoError(err)
426428
receipt := s.WaitForReceipt(hash)
427429
s.Require().True(receipt.Success)
@@ -431,13 +433,13 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
431433
s.Run("Check token is debited from testAddress1_0", func() {
432434
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_0, "latest")
433435
s.Require().NoError(err)
434-
s.Equal(types.NewValueFromUint64(1_000_000-5000-5000), tokens[*tokenTest1.id])
436+
s.Equal(tokenInitial.Sub(tokenToSend).Sub(tokenToSend), tokens[*tokenTest1.id])
435437
})
436438

437439
s.Run("Check token is credited to testAddress1_1", func() {
438440
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_1, "latest")
439441
s.Require().NoError(err)
440-
s.Equal(types.NewValueFromUint64(5000+5000), tokens[*tokenTest1.id])
442+
s.Equal(tokenToSend.Add(tokenToSend), tokens[*tokenTest1.id])
441443
})
442444
})
443445

@@ -450,7 +452,7 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
450452
s.Require().NoError(err)
451453

452454
hash, err := s.Client.SendExternalTransaction(
453-
s.Context, data, s.testAddress1_0, nil, types.NewFeePackFromGas(100_000))
455+
s.Context, data, s.testAddress1_0, nil, defaultFee)
454456
s.Require().NoError(err)
455457
receipt := s.WaitForReceipt(hash)
456458
s.Require().False(receipt.Success)
@@ -459,25 +461,25 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
459461
s.Run("Check token of testAddress1_0", func() {
460462
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_0, "latest")
461463
s.Require().NoError(err)
462-
s.Equal(types.NewValueFromUint64(1_000_000-5000-5000), tokens[*tokenTest1.id])
464+
s.Equal(tokenInitial.Sub(tokenToSend).Sub(tokenToSend), tokens[*tokenTest1.id])
463465
})
464466

465467
s.Run("Check token of testAddress1_1", func() {
466468
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_1, "latest")
467469
s.Require().NoError(err)
468-
s.Equal(types.NewValueFromUint64(5000+5000), tokens[*tokenTest1.id])
470+
s.Equal(tokenToSend.Add(tokenToSend), tokens[*tokenTest1.id])
469471
})
470472
})
471473

472474
amountTest1 := s.getTokenBalance(&s.testAddress1_0, tokenTest1)
473475
amountTest2 := s.getTokenBalance(&s.testAddress1_1, tokenTest1)
474476

475477
s.Run("Call testSendTokensSync", func() {
476-
data, err := s.abiTest.Pack("testSendTokensSync", s.testAddress1_1, big.NewInt(5000), false)
478+
data, err := s.abiTest.Pack("testSendTokensSync", s.testAddress1_1, tokenToSend.ToBig(), false)
477479
s.Require().NoError(err)
478480

479481
hash, err := s.Client.SendExternalTransaction(
480-
s.Context, data, s.testAddress1_0, nil, types.NewFeePackFromGas(100_000))
482+
s.Context, data, s.testAddress1_0, nil, defaultFee)
481483
s.Require().NoError(err)
482484
receipt := s.WaitForReceipt(hash)
483485
s.Require().True(receipt.Success)
@@ -498,44 +500,44 @@ func (s *SuiteMultiTokenRpc) TestMultiToken() { //nolint
498500
})
499501

500502
s.Run("Call testSendTokensSync with fail flag", func() {
501-
data, err := s.abiTest.Pack("testSendTokensSync", s.testAddress1_1, big.NewInt(5000), true)
503+
data, err := s.abiTest.Pack("testSendTokensSync", s.testAddress1_1, tokenToSend.ToBig(), true)
502504
s.Require().NoError(err)
503505

504506
hash, err := s.Client.SendExternalTransaction(
505-
s.Context, data, s.testAddress1_0, nil, types.NewFeePackFromGas(100_000))
507+
s.Context, data, s.testAddress1_0, nil, defaultFee)
506508
s.Require().NoError(err)
507509
receipt := s.WaitForReceipt(hash)
508510
s.Require().False(receipt.Success)
509511

510512
s.Run("Check token of testAddress1_0", func() {
511513
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_0, "latest")
512514
s.Require().NoError(err)
513-
s.Equal(amountTest1.Sub64(5000), tokens[*tokenTest1.id])
515+
s.Equal(amountTest1.Sub(tokenToSend), tokens[*tokenTest1.id])
514516
})
515517

516518
s.Run("Check token of testAddress1_1", func() {
517519
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_1, "latest")
518520
s.Require().NoError(err)
519-
s.Equal(amountTest2.Add64(5000), tokens[*tokenTest1.id])
521+
s.Equal(amountTest2.Add(tokenToSend), tokens[*tokenTest1.id])
520522
})
521523
})
522524

523525
///////////////////////////////////////////////////////////////////////////
524526
// Call `testSendTokensSync` for address in different shard - should fail
525527
s.Run("Fail call testSendTokensSync for address in different shard", func() {
526-
data, err := s.abiTest.Pack("testSendTokensSync", s.smartAccountAddress3, big.NewInt(5000), false)
528+
data, err := s.abiTest.Pack("testSendTokensSync", s.smartAccountAddress3, tokenToSend.ToBig(), false)
527529
s.Require().NoError(err)
528530

529531
hash, err := s.Client.SendExternalTransaction(
530-
s.Context, data, s.testAddress1_0, nil, types.NewFeePackFromGas(100_000))
532+
s.Context, data, s.testAddress1_0, nil, defaultFee)
531533
s.Require().NoError(err)
532534
receipt := s.WaitForReceipt(hash)
533535
s.Require().False(receipt.Success)
534536

535537
s.Run("Check token of testAddress1_0", func() {
536538
tokens, err := s.Client.GetTokens(s.Context, s.testAddress1_0, "latest")
537539
s.Require().NoError(err)
538-
s.Require().Equal(amountTest1.Sub64(5000), tokens[*tokenTest1.id])
540+
s.Require().Equal(amountTest1.Add(tokenToSend), tokens[*tokenTest1.id])
539541
})
540542
})
541543
}

0 commit comments

Comments
 (0)