Skip to content

Commit

Permalink
Added serialisation/deserialisation for Soroban operations and smart …
Browse files Browse the repository at this point in the history
…contract value types

Co-authored-by: Jop Middelkamp <[email protected]>
  • Loading branch information
cuongph87 and jopmiddelkamp authored Jan 3, 2024
1 parent 5c09de2 commit 5e18722
Show file tree
Hide file tree
Showing 386 changed files with 25,095 additions and 12,351 deletions.
4 changes: 4 additions & 0 deletions stellar-dotnet-sdk-console/stellar-dotnet-sdk-console.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
<ProjectReference Include="..\stellar-dotnet-sdk\stellar-dotnet-sdk.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="NSec.Cryptography" Version="22.4.0" />
</ItemGroup>

</Project>
51 changes: 51 additions & 0 deletions stellar-dotnet-sdk-test/AddressTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using stellar_dotnet_sdk;

namespace stellar_dotnet_sdk_test;

[TestClass]
public class AddressTest
{
[TestMethod]
public void TestAccountIdWithInvalidArgument()
{
const string invalidAccountId = "Invalidid";
var ex = Assert.ThrowsException<ArgumentException>(() => new SCAccountId(invalidAccountId));
Assert.AreEqual("Invalid account id (Parameter 'value')", ex.Message);
}

[TestMethod]
public void TestContractIdWithInvalidArgument()
{
const string invalidContractId = "Invalidid";
var ex = Assert.ThrowsException<ArgumentException>(() => new SCContractId(invalidContractId));
Assert.AreEqual("Invalid contract id (Parameter 'value')", ex.Message);
}

[TestMethod]
public void TestAccountIdWithValidArgument()
{
var scAccountId = new SCAccountId("GCZFMH32MF5EAWETZTKF3ZV5SEVJPI53UEMDNSW55WBR75GMZJU4U573");

// Act
var scAccountIdXdrBase64 = scAccountId.ToXdrBase64();
var fromXdrBase64ScAccountId = (SCAccountId)SCVal.FromXdrBase64(scAccountIdXdrBase64);

// Assert
Assert.AreEqual(scAccountId.InnerValue, fromXdrBase64ScAccountId.InnerValue);
}

[TestMethod]
public void TestContractIdWithValidArgument()
{
var scContractId = new SCContractId("CAC2UYJQMC4ISUZ5REYB2AMDC44YKBNZWG4JB6N6GBL66CEKQO3RDSAB");

// Act
var scContractIdXdrBase64 = scContractId.ToXdrBase64();
var fromXdrBase64ScContractId = (SCContractId)SCVal.FromXdrBase64(scContractIdXdrBase64);

// Assert
Assert.AreEqual(scContractId.InnerValue, fromXdrBase64ScContractId.InnerValue);
}
}
Loading

0 comments on commit 5e18722

Please sign in to comment.