Skip to content

Commit

Permalink
Fix bug on specialized Array types
Browse files Browse the repository at this point in the history
  • Loading branch information
mmcs85 committed Mar 28, 2019
1 parent e2a94fb commit 5ecbd6d
Show file tree
Hide file tree
Showing 10 changed files with 85 additions and 13 deletions.
4 changes: 2 additions & 2 deletions EosSharp/EosSharp.Core/Providers/AbiSerializationProvider.cs
Expand Up @@ -697,10 +697,10 @@ private void WriteAbiType(MemoryStream ms, object value, string type, Abi abi)
// array type
if(type.EndsWith("[]"))
{
var items = (IEnumerable<object>)value;
var items = (ICollection)value;
var arrayType = type.Substring(0, type.Length - 2);

WriteVarUint32(ms, items.Count());
WriteVarUint32(ms, items.Count);
foreach (var item in items)
WriteAbiType(ms, item, arrayType, abi);

Expand Down
1 change: 1 addition & 0 deletions EosSharp/EosSharp.UnitTests.Core/EosTestCasesDef.t4
Expand Up @@ -32,6 +32,7 @@
"GetTableRowsGeneric",
"GetProducers",
"GetScheduledTransactions",
"CreateTransactionArrayData",
"CreateTransactionAnonymousObjectData",
"CreateTransaction",
"CreateNewAccount"
Expand Down
26 changes: 25 additions & 1 deletion EosSharp/EosSharp.UnitTests.Core/EosUnitTestCases.cs
@@ -1,7 +1,7 @@
using EosSharp.Core;
using EosSharp.Core.Api.v1;
using EosSharp.Core.Providers;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand Down Expand Up @@ -66,6 +66,30 @@ public Task GetScheduledTransactions()
});
}

public Task CreateTransactionArrayData()
{
return Eos.CreateTransaction(new Transaction()
{
actions = new List<Core.Api.v1.Action>()
{
new Core.Api.v1.Action()
{
account = "platform",
authorization = new List<PermissionLevel>()
{
new PermissionLevel() {actor = "player1", permission = "active" }
},
name = "testarr",
data = new { user = "player1", array = new List<UInt64>() { 1, 6, 3} }
//data = new { user = "player1", array = new UInt64[] { 1, 6, 3} }
//data = new { user = "player1", array = new Queue<UInt64>(new UInt64[] { 1, 6, 3}) }
//data = new { user = "player1", array = new Stack<UInt64>(new UInt64[] { 1, 6, 3}) }
//data = new { user = "player1", array = new ArrayList() { 1, 6, 3} }
}
}
});
}

public Task CreateTransactionAnonymousObjectData()
{
return Eos.CreateTransaction(new Transaction()
Expand Down
19 changes: 19 additions & 0 deletions EosSharp/EosSharp.UnitTests.Unity3D/EosUnitTests.cs
Expand Up @@ -119,6 +119,24 @@ public async Task GetScheduledTransactions()
else
Console.WriteLine("Test GetScheduledTransactions run failed.");
}
public async Task CreateTransactionArrayData()
{
bool success = false;
try
{
await EosUnitTestCases.CreateTransactionArrayData();
success = true;
}
catch (Exception ex)
{
Console.WriteLine(JsonConvert.SerializeObject(ex));
}

if(success)
Console.WriteLine("Test CreateTransactionArrayData run successfuly.");
else
Console.WriteLine("Test CreateTransactionArrayData run failed.");
}
public async Task CreateTransactionAnonymousObjectData()
{
bool success = false;
Expand Down Expand Up @@ -181,6 +199,7 @@ public async Task TestAll()
await GetTableRowsGeneric();
await GetProducers();
await GetScheduledTransactions();
await CreateTransactionArrayData();
await CreateTransactionAnonymousObjectData();
await CreateTransaction();
await CreateNewAccount();
Expand Down
5 changes: 4 additions & 1 deletion EosSharp/EosSharp.UnitTests/ApiUnitTests.cs
Expand Up @@ -23,7 +23,10 @@ public ApiUnitTests()
//HttpEndpoint = "https://nodes.eos42.io", //Mainnet
//ChainId = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"

HttpEndpoint = "https://nodeos01.btuga.io",
//HttpEndpoint = "https://nodeos01.btuga.io",
//ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"

HttpEndpoint = "http://localhost:8888",
ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
};
var eosApi = new EosApi(eosConfig, new HttpHandler());
Expand Down
5 changes: 4 additions & 1 deletion EosSharp/EosSharp.UnitTests/ApiUnitTests.tt
Expand Up @@ -28,7 +28,10 @@ namespace EosSharp.UnitTests
//HttpEndpoint = "https://nodes.eos42.io", //Mainnet
//ChainId = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"

HttpEndpoint = "https://nodeos01.btuga.io",
//HttpEndpoint = "https://nodeos01.btuga.io",
//ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"

HttpEndpoint = "http://localhost:8888",
ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
};
var eosApi = new EosApi(eosConfig, new HttpHandler());
Expand Down
22 changes: 21 additions & 1 deletion EosSharp/EosSharp.UnitTests/EosUnitTests.cs
Expand Up @@ -23,7 +23,10 @@ public EosUnitTests()
//HttpEndpoint = "https://nodes.eos42.io", //Mainnet
//ChainId = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"

HttpEndpoint = "https://nodeos01.btuga.io",
//HttpEndpoint = "https://nodeos01.btuga.io",
//ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"

HttpEndpoint = "http://localhost:8888",
ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
};
var eosApi = new EosApi(eosConfig, new HttpHandler());
Expand Down Expand Up @@ -117,6 +120,23 @@ public async Task GetScheduledTransactions()
}
[TestMethod]
[TestCategory("Eos Tests")]
public async Task CreateTransactionArrayData()
{
bool success = false;
try
{
await EosUnitTestCases.CreateTransactionArrayData();
success = true;
}
catch (Exception ex)
{
Console.WriteLine(JsonConvert.SerializeObject(ex));
}

Assert.IsTrue(success);
}
[TestMethod]
[TestCategory("Eos Tests")]
public async Task CreateTransactionAnonymousObjectData()
{
bool success = false;
Expand Down
5 changes: 4 additions & 1 deletion EosSharp/EosSharp.UnitTests/EosUnitTests.tt
Expand Up @@ -28,7 +28,10 @@ namespace EosSharp.UnitTests
//HttpEndpoint = "https://nodes.eos42.io", //Mainnet
//ChainId = "aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906"

HttpEndpoint = "https://nodeos01.btuga.io",
//HttpEndpoint = "https://nodeos01.btuga.io",
//ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"

HttpEndpoint = "http://localhost:8888",
ChainId = "cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f"
};
var eosApi = new EosApi(eosConfig, new HttpHandler());
Expand Down
2 changes: 1 addition & 1 deletion EosSharp/EosSharp.UnitTests/app.config
Expand Up @@ -5,7 +5,7 @@
<system.net>
<!--Configure fiddler local proxy-->
<!--<defaultProxy>
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:8888" usesystemdefault="false" />
<proxy autoDetect="false" bypassonlocal="false" proxyaddress="http://127.0.0.1:9000" usesystemdefault="false" />
</defaultProxy>-->
</system.net>
</configuration>
9 changes: 4 additions & 5 deletions EosSharp/EosSharp/EosSharp.csproj
Expand Up @@ -13,11 +13,10 @@
<Copyright>Copyright 2019</Copyright>
<Product>eos-sharp</Product>
<PackageId>eos-sharp</PackageId>
<AssemblyVersion>2.0.3.0</AssemblyVersion>
<FileVersion>2.0.3.0</FileVersion>
<Version>2.0.3</Version>
<PackageReleaseNotes>Fix bug on generating key pairs
Fix bug on verifying K1 signatures based on recovery sig param</PackageReleaseNotes>
<AssemblyVersion>2.0.4.0</AssemblyVersion>
<FileVersion>2.0.4.0</FileVersion>
<Version>2.0.4</Version>
<PackageReleaseNotes>Fix bug on specialized Array types</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
</PropertyGroup>

Expand Down

0 comments on commit 5ecbd6d

Please sign in to comment.