Skip to content

Commit ad1197f

Browse files
Added tests that confirm that the WaaS API (and our C# ethereum library) can handle encoding functions with underscores '_' in their names -> motivated by a client issue that seemed like it may be having an issue with this (#173)
1 parent 57ca162 commit ad1197f

4 files changed

Lines changed: 109 additions & 0 deletions

File tree

Assets/SequenceSDK/WaaS/Tests/WalletInteractionsTests.cs

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,5 +426,75 @@ public async Task TestFeeOptionsAndSend()
426426

427427
await tcs.Task;
428428
}
429+
430+
[Test]
431+
public async Task TestInteractingWithContractFunctionsInSnakeCase_LocalABIEncoding()
432+
{
433+
WaaSEndToEndTestConfig config = WaaSEndToEndTestConfig.GetConfig();
434+
var tcs = new TaskCompletionSource<bool>();
435+
EndToEndTestHarness testHarness = new EndToEndTestHarness();
436+
Contract testUnderscores = new Contract("0x8f408550720b268b0ea0969c527ac997d969a638");
437+
438+
testHarness.Login(async wallet =>
439+
{
440+
try
441+
{
442+
TransactionReturn transactionReturn = await wallet.SendTransaction(_chain,
443+
new Transaction[]
444+
{
445+
new RawTransaction(testUnderscores.GetAddress(), "0",
446+
testUnderscores.CallFunction("test_function_name_with_underscores(uint256)", BigInteger.One).CallData)
447+
});
448+
Assert.IsNotNull(transactionReturn);
449+
Assert.IsTrue(transactionReturn is SuccessfulTransactionReturn);
450+
451+
tcs.TrySetResult(true);
452+
}
453+
catch (System.Exception e)
454+
{
455+
tcs.TrySetException(e);
456+
}
457+
}, (error, method, email, methods) =>
458+
{
459+
tcs.TrySetException(new Exception(error));
460+
});
461+
462+
await tcs.Task;
463+
}
464+
465+
[Test]
466+
public async Task TestInteractingWithContractFunctionsInSnakeCase_DelayedServerSideABIEncoding()
467+
{
468+
WaaSEndToEndTestConfig config = WaaSEndToEndTestConfig.GetConfig();
469+
var tcs = new TaskCompletionSource<bool>();
470+
EndToEndTestHarness testHarness = new EndToEndTestHarness();
471+
Contract testUnderscores = new Contract("0x8f408550720b268b0ea0969c527ac997d969a638");
472+
473+
testHarness.Login(async wallet =>
474+
{
475+
try
476+
{
477+
TransactionReturn transactionReturn = await wallet.SendTransaction(_chain,
478+
new Transaction[]
479+
{
480+
new DelayedEncode(testUnderscores.GetAddress(), "0",
481+
new DelayedEncodeData("test_function_name_with_underscores(uint256)", new object[] { "1" }, "test_function_name_with_underscores"))
482+
});
483+
Assert.IsNotNull(transactionReturn);
484+
Assert.IsTrue(transactionReturn is SuccessfulTransactionReturn);
485+
486+
tcs.TrySetResult(true);
487+
}
488+
catch (System.Exception e)
489+
{
490+
tcs.TrySetException(e);
491+
}
492+
}, (error, method, email, methods) =>
493+
{
494+
tcs.TrySetException(new Exception(error));
495+
});
496+
497+
await tcs.Task;
498+
}
429499
}
430500
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"_format": "hh-sol-dbg-1",
3+
"buildInfo": "../../build-info/bb4208cd93884725284d631e62444e66.json"
4+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{
2+
"abi": [
3+
{
4+
"inputs": [
5+
{
6+
"internalType": "uint256",
7+
"name": "number_with_underscore",
8+
"type": "uint256"
9+
}
10+
],
11+
"name": "test_function_name_with_underscores",
12+
"outputs": [
13+
{
14+
"internalType": "uint256",
15+
"name": "",
16+
"type": "uint256"
17+
}
18+
],
19+
"stateMutability": "nonpayable",
20+
"type": "function"
21+
}
22+
],
23+
"bytecode": {
24+
"object": "0x608060405234801561001057600080fd5b5061011b806100206000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80632fd628e514602d575b600080fd5b60436004803603810190603f91906097565b6057565b604051604e919060cc565b60405180910390f35b6000819050919050565b600080fd5b6000819050919050565b6077816066565b8114608157600080fd5b50565b6000813590506091816070565b92915050565b60006020828403121560aa5760a96061565b5b600060b6848285016084565b91505092915050565b60c6816066565b82525050565b600060208201905060df600083018460bf565b9291505056fea2646970667358221220f0bd4ad9f5930efb3a5f117265fcc59cfa61bd68f3923c4666e7291e4d28307a64736f6c63430008110033"
25+
}
26+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
pragma solidity ^0.8.9;
2+
3+
contract TestUnderscores {
4+
function test_function_name_with_underscores(
5+
uint256 number_with_underscore
6+
) public returns (uint256) {
7+
return (number_with_underscore);
8+
}
9+
}

0 commit comments

Comments
 (0)