diff --git a/Assets/SequenceSDK/Ethereum/Tests/ABIRegexTests.cs b/Assets/SequenceSDK/Ethereum/Tests/ABIRegexTests.cs
new file mode 100644
index 000000000..831848255
--- /dev/null
+++ b/Assets/SequenceSDK/Ethereum/Tests/ABIRegexTests.cs
@@ -0,0 +1,41 @@
+using NUnit.Framework;
+using Sequence.Contracts;
+using Assert = UnityEngine.Assertions.Assert;
+
+namespace Sequence.Ethereum.Tests
+{
+ public class ABIRegexTests
+ {
+ [TestCase("", false)]
+ [TestCase("functionName", true)]
+ [TestCase("functionName()", false)]
+ [TestCase("functionName123", true)]
+ [TestCase("functionName_s", true)]
+ [TestCase("function-Name", true)]
+ [TestCase("functionName ", false)]
+ public void TestMatchesFunctionName(string input, bool expected)
+ {
+ bool result = ABIRegex.MatchesFunctionName(input);
+ Assert.AreEqual(expected, result);
+ }
+
+ [TestCase("", false)]
+ [TestCase("functionName", false)]
+ [TestCase("functionName(", false)]
+ [TestCase("functionName()", true)]
+ [TestCase("functionName(a)", true)]
+ [TestCase("functionName(a a)", false)]
+ [TestCase("functionName(a, a)", true)]
+ [TestCase("functionName(a,a)", true)]
+ [TestCase("functionName(,)", false)]
+ [TestCase("functionName(Aa123)", true)]
+ [TestCase("functionName(a,)", false)]
+ [TestCase("functionName() ", false)]
+ [TestCase("function_-123Name()", true)]
+ public void TestMatchesFunctionABI(string input, bool expected)
+ {
+ bool result = ABIRegex.MatchesFunctionABI(input);
+ Assert.AreEqual(expected, result);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/SequenceSDK/Ethereum/Tests/ABIRegexTests.cs.meta b/Assets/SequenceSDK/Ethereum/Tests/ABIRegexTests.cs.meta
new file mode 100644
index 000000000..4d92333aa
--- /dev/null
+++ b/Assets/SequenceSDK/Ethereum/Tests/ABIRegexTests.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 9727550d4e3345baa3db78aa64d3c811
+timeCreated: 1727361762
\ No newline at end of file
diff --git a/Assets/SequenceSDK/Ethereum/Tests/ContractIntegrationTests.cs b/Assets/SequenceSDK/Ethereum/Tests/ContractIntegrationTests.cs
index 0e0c4e23d..ad3365323 100644
--- a/Assets/SequenceSDK/Ethereum/Tests/ContractIntegrationTests.cs
+++ b/Assets/SequenceSDK/Ethereum/Tests/ContractIntegrationTests.cs
@@ -93,5 +93,121 @@ public async Task TestComplexContract()
CollectionAssert.AreEqual(expectedMoreBytes.Data, (byte[])resultPart2[3]);
CollectionAssert.AreEqual(expectedAddresses, resultPart2[4].ConvertToTArray
());
}
+
+ [Test]
+ public void TestInvalidRegex_noABI()
+ {
+ Contract complexContract = new Contract(complexContractAddress);
+
+ try
+ {
+ complexContract.QueryContract("functionName");
+ Assert.Fail("Expected exception but none was thrown");
+ }
+ catch (ArgumentException e)
+ {
+
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Expected argument exception");
+ }
+
+ try
+ {
+ complexContract.QueryContract("functionName(");
+ Assert.Fail("Expected exception but none was thrown");
+ }
+ catch (ArgumentException e)
+ {
+
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Expected argument exception");
+ }
+
+ try
+ {
+ complexContract.QueryContract("functionName)");
+ Assert.Fail("Expected exception but none was thrown");
+ }
+ catch (ArgumentException e)
+ {
+
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Expected argument exception");
+ }
+
+ try
+ {
+ complexContract.AssembleCallData("functionName(uint banana)", 1);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("No exception expected");
+ }
+
+
+ try
+ {
+ complexContract.CallFunction("functionName(uint, uint)", 1, 1);
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("No exception expected");
+ }
+ }
+
+ [Test]
+ public void TestInvalidRegex_withABI()
+ {
+ Contract complexContract = new Contract(complexContractAddress, complexContractAbi);
+
+ try
+ {
+ complexContract.QueryContract("functionName()");
+ Assert.Fail("Expected exception but none was thrown");
+ }
+ catch (ArgumentException e)
+ {
+
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Expected argument exception");
+ }
+
+ try
+ {
+ complexContract.AssembleCallData("functionName(uint banana)");
+ Assert.Fail("Expected exception but none was thrown");
+ }
+ catch (ArgumentException e)
+ {
+
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Expected argument exception");
+ }
+
+
+ try
+ {
+ complexContract.CallFunction("functionName*");
+ Assert.Fail("Expected exception but none was thrown");
+ }
+ catch (ArgumentException e)
+ {
+
+ }
+ catch (Exception e)
+ {
+ Assert.Fail("Expected argument exception");
+ }
+ }
}
}
diff --git a/Assets/SequenceSDK/Ethereum/Tests/WalletTests.cs b/Assets/SequenceSDK/Ethereum/Tests/WalletTests.cs
index b35e2f377..516ce7d54 100644
--- a/Assets/SequenceSDK/Ethereum/Tests/WalletTests.cs
+++ b/Assets/SequenceSDK/Ethereum/Tests/WalletTests.cs
@@ -178,7 +178,7 @@ public async Task TestChain_ERC20Mock_MockMint_Test()
EOAWallet wallet2 = new EOAWallet("0xabc0000000000000000000000000000000000000000000000000000000000002");
Contract mockERC20 = new Contract(receipt.contractAddress);
string result = await mockERC20.SendTransactionMethod(wallet2, client, 0,
- "mockMint(address , uint256)",
+ "mockMint(address, uint256)",
wallet2.GetAddress(), 1);
Assert.IsNotNull(result);
}
diff --git a/Assets/SequenceSDK/WaaS/Tests/DelayedEncodeJsonSerializationTest.cs b/Assets/SequenceSDK/WaaS/Tests/DelayedEncodeJsonSerializationTest.cs
index 52ddd529d..c7ddee38c 100644
--- a/Assets/SequenceSDK/WaaS/Tests/DelayedEncodeJsonSerializationTest.cs
+++ b/Assets/SequenceSDK/WaaS/Tests/DelayedEncodeJsonSerializationTest.cs
@@ -52,5 +52,23 @@ public void TestDelayedEncodeDataArgsGetsSerializedAlphabetically()
Assert.AreEqual("{\"abi\":\"testAbi(string,ComplexObjectInNonAlphabeticalOrder,int)\",\"args\":[\"some string\",{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},1,5,[1,{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},null,\"banana\"],[{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},null],[1,[2,{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},3,{\"ComplexObjectArray\":[null,{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"}],\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"}],\"word\"]],\"func\":\"testFunc\"}", json);
}
+
+ [Test]
+ public void TestAbiDataArgsGetsSerializedAlphabetically()
+ {
+ AbiData testData = new AbiData("testAbi(string,ComplexObjectInNonAlphabeticalOrder,int)",
+ new object[] { "some string", new ComplexObjectInNonAlphabeticalOrder("last", "first", "halfway"),
+ BigInteger.One, 5, new object[] { 1, new ComplexObjectInNonAlphabeticalOrder("last", "first", "halfway"), null, "banana" },
+ new ComplexObjectInNonAlphabeticalOrder[] { new ("last", "first", "halfway"), null },
+ new object[] { 1, new object[] { 2, new ComplexObjectInNonAlphabeticalOrder("last", "first", "halfway"), 3,
+ new ExtraComplexObjectWithComplexObjectArray("last", new ComplexObjectInNonAlphabeticalOrder[] { null,
+ new ("last", "first", "halfway")}, "halfway")}, "word"}
+ });
+
+ string json = JsonConvert.SerializeObject(testData);
+ Debug.Log(json);
+
+ Assert.AreEqual("{\"abi\":\"testAbi(string,ComplexObjectInNonAlphabeticalOrder,int)\",\"args\":[\"some string\",{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},1,5,[1,{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},null,\"banana\"],[{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},null],[1,[2,{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"},3,{\"ComplexObjectArray\":[null,{\"FirstValue\":\"first\",\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"}],\"HalfwayValue\":\"halfway\",\"LastValue\":\"last\"}],\"word\"]]}", json);
+ }
}
}
\ No newline at end of file
diff --git a/Assets/SequenceSDK/WaaS/Tests/WaaSWalletUnitTests.cs b/Assets/SequenceSDK/WaaS/Tests/WaaSWalletUnitTests.cs
index 364e8fa8a..559451096 100644
--- a/Assets/SequenceSDK/WaaS/Tests/WaaSWalletUnitTests.cs
+++ b/Assets/SequenceSDK/WaaS/Tests/WaaSWalletUnitTests.cs
@@ -29,7 +29,7 @@ public async Task TestSendTransactionSuccessEvent()
failedEventHit = true;
};
- await wallet.SendTransaction(Chain.None, null);
+ await wallet.SendTransaction(Chain.None, Array.Empty());
Assert.IsTrue(successEventHit);
Assert.IsFalse(failedEventHit);
@@ -52,12 +52,117 @@ public async Task TestSendTransactionFailedEvent()
failedEventHit = true;
};
- await wallet.SendTransaction(Chain.None, null);
+ await wallet.SendTransaction(Chain.None, Array.Empty());
Assert.IsFalse(successEventHit);
Assert.IsTrue(failedEventHit);
}
+ private static (DelayedEncodeData, bool)[] _invalidDelayedEncodeData = new[]
+ {
+ (new DelayedEncodeData("functionName", Array.Empty