|
9 | 9 | using Sequence.Authentication; |
10 | 10 | using Sequence.Contracts; |
11 | 11 | using Sequence.Ethereum.Tests; |
| 12 | +using Sequence.Provider; |
12 | 13 | using Sequence.Utils; |
13 | 14 | using Sequence.Wallet; |
14 | 15 |
|
@@ -553,5 +554,68 @@ public async Task TestInteractingWithContractFunctionsInSnakeCase_DelayedServerS |
553 | 554 |
|
554 | 555 | await tcs.Task; |
555 | 556 | } |
| 557 | + |
| 558 | + [Test] |
| 559 | + public async Task TestInteractWithTupleContract() |
| 560 | + { |
| 561 | + var tcs = new TaskCompletionSource<bool>(); |
| 562 | + EndToEndTestHarness testHarness = new EndToEndTestHarness(); |
| 563 | + Contract contract = new Contract("0x88e57238a23e2619fd42f479d546560b44c698fe"); |
| 564 | + IEthClient client = new SequenceEthClient(Chain.ArbitrumNova); |
| 565 | + |
| 566 | + Address someAddress = new Address("0x8f408550720b268b0ea0969c527ac997d969a638"); |
| 567 | + Address anotherAddress = new Address("0x38104f7bb130756dcdd24d804e3e2d2e9df25d7d"); |
| 568 | + byte[] data = "Something".ToByteArray(); |
| 569 | + int integer = 3; |
| 570 | + string first = "firstWord"; |
| 571 | + string second = "secondWord"; |
| 572 | + int number = 7; |
| 573 | + |
| 574 | + testHarness.Login(async wallet => |
| 575 | + { |
| 576 | + try |
| 577 | + { |
| 578 | + TransactionReturn transactionReturn = await wallet.SendTransaction(_chain, |
| 579 | + new Transaction[] |
| 580 | + { |
| 581 | + new SequenceContractCall(contract.GetAddress(), |
| 582 | + new AbiData("testTuple((address,string),(string,address,bytes,uint),int)", new object[] |
| 583 | + { |
| 584 | + (someAddress, first), |
| 585 | + (second, anotherAddress, data, integer.ToString()), |
| 586 | + number.ToString() |
| 587 | + })) |
| 588 | + }); |
| 589 | + Assert.IsNotNull(transactionReturn); |
| 590 | + Assert.IsTrue(transactionReturn is SuccessfulTransactionReturn); |
| 591 | + |
| 592 | + Address storedAddress = await contract.QueryContract<Address>("getStoredAddress").Invoke(client); |
| 593 | + Assert.AreEqual(someAddress, storedAddress); |
| 594 | + Address storedAddress2 = await contract.QueryContract<Address>("getStoredAddress2").Invoke(client); |
| 595 | + Assert.AreEqual(anotherAddress, storedAddress2); |
| 596 | + byte[] storedBytes = await contract.QueryContract<byte[]>("getStoredBytes").Invoke(client); |
| 597 | + Assert.AreEqual(data, storedBytes); |
| 598 | + int storedInt = await contract.QueryContract<int>("getStoredInt").Invoke(client); |
| 599 | + Assert.AreEqual(integer, storedInt); |
| 600 | + string storedString = await contract.QueryContract<string>("getStoredString").Invoke(client); |
| 601 | + Assert.AreEqual(first, storedString); |
| 602 | + string storedString2 = await contract.QueryContract<string>("getStoredString2").Invoke(client); |
| 603 | + Assert.AreEqual(second, storedString2); |
| 604 | + uint storedUint = await contract.QueryContract<uint>("getStoredUint").Invoke(client); |
| 605 | + Assert.AreEqual(number, storedUint); |
| 606 | + |
| 607 | + tcs.TrySetResult(true); |
| 608 | + } |
| 609 | + catch (System.Exception e) |
| 610 | + { |
| 611 | + tcs.TrySetException(e); |
| 612 | + } |
| 613 | + }, (error, method, email, methods) => |
| 614 | + { |
| 615 | + tcs.TrySetException(new Exception(error)); |
| 616 | + }); |
| 617 | + |
| 618 | + await tcs.Task; |
| 619 | + } |
556 | 620 | } |
557 | 621 | } |
0 commit comments