From 36f35f67c55b52fe680b78e24e453232a14196c2 Mon Sep 17 00:00:00 2001 From: Quinn Purdy Date: Thu, 30 Nov 2023 11:35:14 -0500 Subject: [PATCH] Fix broken tests. Wrap WaaSWalletTests in try catches to catch any exceptions thrown throughout and fail the test - otherwise, the tests fail silently and the WaaSTestHarness never outputs the results (as it doesn't receive all the expected pass/fail events --- Assets/SequenceSDK/WaaS/Tests/CustomAssert.cs | 14 +- .../SequenceSDK/WaaS/Tests/WaaSTestHarness.cs | 9 +- .../SequenceSDK/WaaS/Tests/WaaSWalletTests.cs | 345 ++++++++++-------- 3 files changed, 215 insertions(+), 153 deletions(-) diff --git a/Assets/SequenceSDK/WaaS/Tests/CustomAssert.cs b/Assets/SequenceSDK/WaaS/Tests/CustomAssert.cs index 2fe85682..b1fa4455 100644 --- a/Assets/SequenceSDK/WaaS/Tests/CustomAssert.cs +++ b/Assets/SequenceSDK/WaaS/Tests/CustomAssert.cs @@ -4,13 +4,15 @@ namespace Sequence.WaaS.Tests { public static class CustomAssert { - public static Exception TestFailedException; + public static Exception TestFailedException(string reason) + { + return new Exception(reason); + } public static void NotNull(object obj, string name, params object[] args) { if (obj == null) { - WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(name, args)); - throw TestFailedException; + throw TestFailedException($"{obj} was null"); } } @@ -18,8 +20,7 @@ public static void IsTrue(bool condition, string name, params object[] args) { if (!condition) { - WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(name, args)); - throw TestFailedException; + throw TestFailedException($"Condition was not true"); } } @@ -27,8 +28,7 @@ public static void IsEqual(object expected, object actual, string name, params o { if (!expected.Equals(actual)) { - WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(name, args)); - throw TestFailedException; + throw TestFailedException($"Expected {expected} is not equal to Actual {actual}"); } } } diff --git a/Assets/SequenceSDK/WaaS/Tests/WaaSTestHarness.cs b/Assets/SequenceSDK/WaaS/Tests/WaaSTestHarness.cs index ec5ffe39..c277d940 100644 --- a/Assets/SequenceSDK/WaaS/Tests/WaaSTestHarness.cs +++ b/Assets/SequenceSDK/WaaS/Tests/WaaSTestHarness.cs @@ -59,9 +59,15 @@ private void InitiateTests(WaaSWallet wallet) TestPassed += () => _passedTests++; TestStarted += () => _testsStarted++; WaaSWalletTests walletTests = new WaaSWalletTests(wallet); + wallet.OnSendTransactionFailed += OnFailedTransaction; RunTests(walletTests); } + private void OnFailedTransaction(FailedTransactionReturn result) + { + Debug.LogError("Transaction failed: " + result.error); + } + private async Task RunTests(WaaSWalletTests walletTests) { walletTests.TestMessageSigning("Hello world", Chain.Polygon); @@ -82,9 +88,10 @@ private async Task RunTests(WaaSWalletTests walletTests) public class WaaSTestFailed { public string Name; + public string Reason; public object[] Args; - public WaaSTestFailed(string name, params object[] args) + public WaaSTestFailed(string name, string reason, params object[] args) { Name = name; Args = args; diff --git a/Assets/SequenceSDK/WaaS/Tests/WaaSWalletTests.cs b/Assets/SequenceSDK/WaaS/Tests/WaaSWalletTests.cs index 045f32e3..58dec96c 100644 --- a/Assets/SequenceSDK/WaaS/Tests/WaaSWalletTests.cs +++ b/Assets/SequenceSDK/WaaS/Tests/WaaSWalletTests.cs @@ -20,7 +20,9 @@ public class WaaSWalletTests private string _polygonNode = "https://polygon-bor.publicnode.com"; private string _erc20Address = "0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359"; private string _erc721Address = "0xa9a6A3626993D487d2Dbda3173cf58cA1a9D9e9f"; + private string _erc721TokenId = "54530968763798660137294927684252503703134533114052628080002308208148824588621"; private string _erc1155Address = "0x44b3f42e2bf34f62868ff9e9dab7c2f807ba97cb"; + private string _erc1155TokenId = "86"; private IIndexer _polygonIndexer = new ChainIndexer((int)Chain.Polygon); private IEthClient _client; @@ -40,62 +42,89 @@ private async Task GetAddress() public async Task TestMessageSigning(string message, Chain network) { - WaaSTestHarness.TestStarted?.Invoke(); - var result = await _wallet.SignMessage(new SignMessageArgs(_address, network, message)); - string signature = result.signature; - CustomAssert.NotNull(signature, nameof(TestMessageSigning), message, network); - var ethWallet = new EthWallet(); - var networkId = (BigInteger)(int)network; - var isValid = await ethWallet.IsValidSignature(signature, message, networkId.BigIntegerToHexString()); // Todo replace: this checks if the signature was signed by the EthWallet, I want to check that it was signed by my WaaS wallet - CustomAssert.IsTrue(isValid, nameof(TestMessageSigning), message, network); - WaaSTestHarness.TestPassed?.Invoke(); + try + { + WaaSTestHarness.TestStarted?.Invoke(); + var result = await _wallet.SignMessage(new SignMessageArgs(_address, network, message)); + string signature = result.signature; + CustomAssert.NotNull(signature, nameof(TestMessageSigning), message, network); + var ethWallet = new EthWallet(); + var networkId = (BigInteger)(int)network; + var isValid = + await ethWallet.IsValidSignature(signature, message, + networkId + .BigIntegerToHexString()); // Todo replace: this checks if the signature was signed by the EthWallet, I want to check that it was signed by my WaaS wallet + CustomAssert.IsTrue(isValid, nameof(TestMessageSigning), message, network); + WaaSTestHarness.TestPassed?.Invoke(); + } + catch (Exception e) + { + WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestMessageSigning), e.Message, message, network)); + } } public async Task TestTransfer() { - WaaSTestHarness.TestStarted?.Invoke(); - - var balance = await _client.BalanceAt(_address); - var balance2 = await _client.BalanceAt(_toAddress); - TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, Chain.Polygon, - new SequenceSDK.WaaS.Transaction[] - { - new RawTransaction(_toAddress, "1"), - })); - var newBalance = await _client.BalanceAt(_address); - var newBalance2 = await _client.BalanceAt(_toAddress); - CustomAssert.IsTrue(result is SuccessfulTransactionReturn, nameof(TestTransfer)); - CustomAssert.IsTrue(newBalance < balance, nameof(TestTransfer)); - CustomAssert.IsTrue(newBalance2 > balance2, nameof(TestTransfer)); - WaaSTestHarness.TestPassed?.Invoke(); + try + { + WaaSTestHarness.TestStarted?.Invoke(); + var balance = await _client.BalanceAt(_address); + var balance2 = await _client.BalanceAt(_toAddress); + + TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, + Chain.Polygon, + new SequenceSDK.WaaS.Transaction[] + { + new RawTransaction(_toAddress, "1"), + })); + + var newBalance = await _client.BalanceAt(_address); + var newBalance2 = await _client.BalanceAt(_toAddress); + CustomAssert.IsTrue(result is SuccessfulTransactionReturn, nameof(TestTransfer)); + CustomAssert.IsTrue(newBalance < balance, nameof(TestTransfer)); + CustomAssert.IsTrue(newBalance2 > balance2, nameof(TestTransfer)); + WaaSTestHarness.TestPassed?.Invoke(); + } + catch (Exception e) + { + WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestTransfer), e.Message)); + } } public async Task TestSendERC20() { - WaaSTestHarness.TestStarted?.Invoke(); - GetTokenBalancesReturn tokenBalances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); - BigInteger balance = tokenBalances.balances[0].balance; - GetTokenBalancesReturn tokenBalances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); - BigInteger balance2 = tokenBalances2.balances[0].balance; - - TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, Chain.Polygon, - new SequenceSDK.WaaS.Transaction[] - { - new SendERC20(_erc20Address, _toAddress, "1"), - })); - - CustomAssert.IsTrue(result is SuccessfulTransactionReturn, nameof(TestSendERC20)); - GetTokenBalancesReturn newTokenBalances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); - BigInteger newBalance = newTokenBalances.balances[0].balance; - GetTokenBalancesReturn newTokenBalances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); - BigInteger newBalance2 = newTokenBalances2.balances[0].balance; - CustomAssert.IsTrue(newBalance < balance, nameof(TestSendERC20)); - CustomAssert.IsTrue(newBalance2 > balance2, nameof(TestSendERC20)); - WaaSTestHarness.TestPassed?.Invoke(); + try + { + WaaSTestHarness.TestStarted?.Invoke(); + GetTokenBalancesReturn tokenBalances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); + BigInteger balance = tokenBalances.balances[0].balance; + GetTokenBalancesReturn tokenBalances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); + BigInteger balance2 = tokenBalances2.balances[0].balance; + + TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, + Chain.Polygon, + new SequenceSDK.WaaS.Transaction[] + { + new SendERC20(_erc20Address, _toAddress, "1"), + })); + + CustomAssert.IsTrue(result is SuccessfulTransactionReturn, nameof(TestSendERC20)); + GetTokenBalancesReturn newTokenBalances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); + BigInteger newBalance = newTokenBalances.balances[0].balance; + GetTokenBalancesReturn newTokenBalances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); + BigInteger newBalance2 = newTokenBalances2.balances[0].balance; + CustomAssert.IsTrue(newBalance < balance, nameof(TestSendERC20)); + CustomAssert.IsTrue(newBalance2 > balance2, nameof(TestSendERC20)); + WaaSTestHarness.TestPassed?.Invoke(); + } + catch (Exception e) + { + WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestSendERC20), e.Message)); + } } // Note: since we are using real tokens, sending ERC721s and ERC1155s multiple times in a single test suite is difficult @@ -103,113 +132,139 @@ public async Task TestSendERC20() // we do them as part of batch transactions. We don't have this issue with ERC20s as we can batch multiple transactions together public async Task TestSendBatchTransaction_withERC721() { - WaaSTestHarness.TestStarted?.Invoke(); - BigInteger balance = await _client.BalanceAt(_address); - GetTokenBalancesReturn erc20Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); - BigInteger erc20Balance = erc20Balances.balances[0].balance; - GetTokenBalancesReturn erc721Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc721Address)); - BigInteger erc721Balance = erc721Balances.balances[0].balance; - if (erc721Balance == 0) + try { - Debug.LogError($"Test {nameof(TestSendBatchTransaction_withERC721)} was not setup properly. {_address} must have an NFT from contract address: {_erc721Address}"); - WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestSendBatchTransaction_withERC721))); - throw TestNotSetupProperly; - } - BigInteger balance2 = await _client.BalanceAt(_toAddress); - GetTokenBalancesReturn erc20Balances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); - BigInteger erc20Balance2 = erc20Balances2.balances[0].balance; - - TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, Chain.Polygon, - new SequenceSDK.WaaS.Transaction[] + WaaSTestHarness.TestStarted?.Invoke(); + BigInteger balance = await _client.BalanceAt(_address); + GetTokenBalancesReturn erc20Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); + BigInteger erc20Balance = erc20Balances.balances[0].balance; + GetTokenBalancesReturn erc721Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc721Address)); + BigInteger erc721Balance = erc721Balances.balances[0].balance; + if (erc721Balance == 0) { - new SendERC20(_erc20Address, _toAddress, "1"), - new SendERC721(_erc721Address, _toAddress, "1"), - new RawTransaction(_toAddress, "1") - })); - CustomAssert.IsTrue(result is SuccessfulTransactionReturn, nameof(TestSendBatchTransaction_withERC721)); - - BigInteger newBalance = await _client.BalanceAt(_address); - GetTokenBalancesReturn newErc20Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); - BigInteger newErc20Balance = newErc20Balances.balances[0].balance; - GetTokenBalancesReturn newErc721Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc721Address)); - BigInteger newErc721Balance = newErc721Balances.balances[0].balance; - BigInteger newBalance2 = await _client.BalanceAt(_toAddress); - GetTokenBalancesReturn newErc20Balances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); - BigInteger newErc20Balance2 = newErc20Balances2.balances[0].balance; - GetTokenBalancesReturn newErc721Balances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc721Address)); - BigInteger newErc721Balance2 = newErc721Balances2.balances[0].balance; + string failReason = + $"Test {nameof(TestSendBatchTransaction_withERC721)} was not setup properly. {_address} must have an NFT from contract address: {_erc721Address}"; + Debug.LogError(failReason); + WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestSendBatchTransaction_withERC721), + failReason)); + throw TestNotSetupProperly; + } + + BigInteger balance2 = await _client.BalanceAt(_toAddress); + GetTokenBalancesReturn erc20Balances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); + BigInteger erc20Balance2 = erc20Balances2.balances[0].balance; + + TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, + Chain.Polygon, + new SequenceSDK.WaaS.Transaction[] + { + new SendERC20(_erc20Address, _toAddress, "1"), + new SendERC721(_erc721Address, _toAddress, _erc721TokenId), + new RawTransaction(_toAddress, "1") + })); + CustomAssert.IsTrue(result is SuccessfulTransactionReturn, nameof(TestSendBatchTransaction_withERC721)); + + BigInteger newBalance = await _client.BalanceAt(_address); + GetTokenBalancesReturn newErc20Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); + BigInteger newErc20Balance = newErc20Balances.balances[0].balance; + GetTokenBalancesReturn newErc721Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc721Address)); + BigInteger newBalance2 = await _client.BalanceAt(_toAddress); + GetTokenBalancesReturn newErc20Balances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); + BigInteger newErc20Balance2 = newErc20Balances2.balances[0].balance; + GetTokenBalancesReturn newErc721Balances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc721Address)); + BigInteger newErc721Balance2 = newErc721Balances2.balances[0].balance; + + CustomAssert.IsTrue(balance > newBalance, nameof(TestSendBatchTransaction_withERC721)); + CustomAssert.IsTrue(erc20Balance > newErc20Balance, nameof(TestSendBatchTransaction_withERC721)); + CustomAssert.IsTrue(newErc721Balances.balances.Length == 0, + nameof(TestSendBatchTransaction_withERC721)); + CustomAssert.IsTrue(balance2 < newBalance2, nameof(TestSendBatchTransaction_withERC721)); + CustomAssert.IsTrue(erc20Balance2 < newErc20Balance2, nameof(TestSendBatchTransaction_withERC721)); + CustomAssert.IsTrue(newErc721Balance2 == 1, nameof(TestSendBatchTransaction_withERC721)); + WaaSTestHarness.TestPassed?.Invoke(); + } + catch (Exception e) + { + WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestSendBatchTransaction_withERC721), e.Message)); - CustomAssert.IsTrue(balance < newBalance, nameof(TestSendBatchTransaction_withERC721)); - CustomAssert.IsTrue(erc20Balance < newErc20Balance, nameof(TestSendBatchTransaction_withERC721)); - CustomAssert.IsTrue(newErc721Balance == 0, nameof(TestSendBatchTransaction_withERC721)); - CustomAssert.IsTrue(balance2 > newBalance2, nameof(TestSendBatchTransaction_withERC721)); - CustomAssert.IsTrue(erc20Balance2 > newErc20Balance2, nameof(TestSendBatchTransaction_withERC721)); - CustomAssert.IsTrue(newErc721Balance2 == 1, nameof(TestSendBatchTransaction_withERC721)); - WaaSTestHarness.TestPassed?.Invoke(); + } } public async Task TestSendBatchTransaction_withERC1155() { - WaaSTestHarness.TestStarted?.Invoke(); - BigInteger balance = await _client.BalanceAt(_address); - GetTokenBalancesReturn erc20Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); - BigInteger erc20Balance = erc20Balances.balances[0].balance; - GetTokenBalancesReturn erc1155Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc1155Address)); - BigInteger erc11155Balance = erc1155Balances.balances[0].balance; - if (erc11155Balance == 0) + try { - Debug.LogError($"Test {nameof(TestSendBatchTransaction_withERC1155)} was not setup properly. {_address} must have an SFT from contract address: {_erc1155Address}"); - WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestSendBatchTransaction_withERC1155))); - throw TestNotSetupProperly; - } - BigInteger balance2 = await _client.BalanceAt(_toAddress); - GetTokenBalancesReturn erc20Balances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); - BigInteger erc20Balance2 = erc20Balances2.balances[0].balance; - - TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, Chain.Polygon, - new SequenceSDK.WaaS.Transaction[] + WaaSTestHarness.TestStarted?.Invoke(); + BigInteger balance = await _client.BalanceAt(_address); + GetTokenBalancesReturn erc20Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); + BigInteger erc20Balance = erc20Balances.balances[0].balance; + GetTokenBalancesReturn erc1155Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc1155Address)); + BigInteger erc11155Balance = erc1155Balances.balances[0].balance; + if (erc11155Balance == 0) { - new SendERC20(_erc20Address, _toAddress, "1"), - new SendERC1155(_erc1155Address, _toAddress, new SendERC1155Values[] + string failReason = + $"Test {nameof(TestSendBatchTransaction_withERC1155)} was not setup properly. {_address} must have an SFT from contract address: {_erc1155Address}"; + Debug.LogError(failReason); + WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestSendBatchTransaction_withERC1155), + failReason)); + throw TestNotSetupProperly; + } + + BigInteger balance2 = await _client.BalanceAt(_toAddress); + GetTokenBalancesReturn erc20Balances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); + BigInteger erc20Balance2 = erc20Balances2.balances[0].balance; + + TransactionReturn result = await _wallet.SendTransaction(new SendTransactionArgs(_address, + Chain.Polygon, + new SequenceSDK.WaaS.Transaction[] { - new SendERC1155Values("86", "1") - }), - new RawTransaction(_toAddress, "1") - })); - CustomAssert.IsTrue(result is SuccessfulTransactionReturn, nameof(TestSendBatchTransaction_withERC1155)); - - BigInteger newBalance = await _client.BalanceAt(_address); - GetTokenBalancesReturn newErc20Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); - BigInteger newErc20Balance = newErc20Balances.balances[0].balance; - GetTokenBalancesReturn newErc1155Balances = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc1155Address)); - BigInteger newErc721Balance = newErc1155Balances.balances[0].balance; - BigInteger newBalance2 = await _client.BalanceAt(_toAddress); - GetTokenBalancesReturn newErc20Balances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); - BigInteger newErc20Balance2 = newErc20Balances2.balances[0].balance; - GetTokenBalancesReturn newErc1155Balances2 = - await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc1155Address)); - BigInteger newErc1155Balance2 = newErc1155Balances2.balances[0].balance; - - CustomAssert.IsTrue(balance < newBalance, nameof(TestSendBatchTransaction_withERC1155)); - CustomAssert.IsTrue(erc20Balance < newErc20Balance, nameof(TestSendBatchTransaction_withERC1155)); - CustomAssert.IsTrue(newErc721Balance == 0, nameof(TestSendBatchTransaction_withERC1155)); - CustomAssert.IsTrue(balance2 > newBalance2, nameof(TestSendBatchTransaction_withERC1155)); - CustomAssert.IsTrue(erc20Balance2 > newErc20Balance2, nameof(TestSendBatchTransaction_withERC1155)); - CustomAssert.IsTrue(newErc1155Balance2 == 1, nameof(TestSendBatchTransaction_withERC1155)); - WaaSTestHarness.TestPassed?.Invoke(); + new SendERC20(_erc20Address, _toAddress, "1"), + new SendERC1155(_erc1155Address, _toAddress, new SendERC1155Values[] + { + new SendERC1155Values(_erc1155TokenId, "1") + }), + new RawTransaction(_toAddress, "1") + })); + CustomAssert.IsTrue(result is SuccessfulTransactionReturn, + nameof(TestSendBatchTransaction_withERC1155)); + + BigInteger newBalance = await _client.BalanceAt(_address); + GetTokenBalancesReturn newErc20Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc20Address)); + BigInteger newErc20Balance = newErc20Balances.balances[0].balance; + GetTokenBalancesReturn newErc1155Balances = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_address, _erc1155Address)); + BigInteger newBalance2 = await _client.BalanceAt(_toAddress); + GetTokenBalancesReturn newErc20Balances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc20Address)); + BigInteger newErc20Balance2 = newErc20Balances2.balances[0].balance; + GetTokenBalancesReturn newErc1155Balances2 = + await _polygonIndexer.GetTokenBalances(new GetTokenBalancesArgs(_toAddress, _erc1155Address)); + BigInteger newErc1155Balance2 = newErc1155Balances2.balances[0].balance; + + CustomAssert.IsTrue(balance > newBalance, nameof(TestSendBatchTransaction_withERC1155)); + CustomAssert.IsTrue(erc20Balance > newErc20Balance, nameof(TestSendBatchTransaction_withERC1155)); + CustomAssert.IsTrue(newErc1155Balances.balances.Length == 0, + nameof(TestSendBatchTransaction_withERC1155)); + CustomAssert.IsTrue(balance2 < newBalance2, nameof(TestSendBatchTransaction_withERC1155)); + CustomAssert.IsTrue(erc20Balance2 < newErc20Balance2, nameof(TestSendBatchTransaction_withERC1155)); + CustomAssert.IsTrue(newErc1155Balance2 == 1, nameof(TestSendBatchTransaction_withERC1155)); + WaaSTestHarness.TestPassed?.Invoke(); + } + catch (Exception e) + { + WaaSTestHarness.TestFailed?.Invoke(new WaaSTestFailed(nameof(TestSendBatchTransaction_withERC1155), e.Message)); + } } } } \ No newline at end of file