Skip to content

Commit

Permalink
Fixed UT (Neo CI01089) (neo-project#416)
Browse files Browse the repository at this point in the history
* [RpcServer] Querying contracts by ID/name (neo-project#378)

* fixed-bug-1021

* Update src/RpcServer/RpcServer.SmartContract.cs

* 😂

* draft

* draft

* update

* fixed bug with decimal of GAS consumed in invokefunction/invokescript

* remove modify of invokescript

* Querying contracts by ID/name, server side

* update

* Enable using native.name for search

Enable using native.name for search

* Using keyword instead of addressOrScriptHash

* revert

* _initialize

* split

* update

* Update exception message in ApplicationLog

* Update src/ApplicationLogs/LogReader.cs

Co-authored-by: Luchuan <[email protected]>

* update

* a

* More fix

* fix

* Fixed UT

* Simplify Code

* Simplify Code 2

* Update RpcServer

* update

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>

* MPT in StateService from core (neo-project#410)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal (neo-project#413)

* Unify GetUnclaimedGas and GetWalletUnclaimedGas with decimal

* fix

* Fixed UT (Neo CI01089)

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Owen Zhang <[email protected]>
Co-authored-by: superboyiii <[email protected]>
Co-authored-by: Vitor Nazário Coelho <[email protected]>
Co-authored-by: Luchuan <[email protected]>
Co-authored-by: ZhangTao <[email protected]>
  • Loading branch information
7 people committed Dec 10, 2020
1 parent 0799d85 commit b522dce
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 70 deletions.
2 changes: 1 addition & 1 deletion src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Neo" Version="3.0.0-CI01066" />
<PackageReference Include="Neo" Version="3.0.0-CI01089" />
</ItemGroup>

</Project>
2 changes: 2 additions & 0 deletions src/RpcClient/Models/RpcContractState.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using Neo;
using Neo.IO.Json;
using Neo.Ledger;
using Neo.SmartContract.Manifest;
Expand All @@ -19,6 +20,7 @@ public static RpcContractState FromJson(JObject json)
ContractState = new ContractState
{
Id = (int)json["id"].AsNumber(),
Hash = UInt160.Parse(json["hash"].AsString()),
Script = Convert.FromBase64String(json["script"].AsString()),
Manifest = ContractManifest.FromJson(json["manifest"])
}
Expand Down
1 change: 1 addition & 0 deletions src/RpcClient/RpcClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ public static ContractState ContractStateFromJson(JObject json)
return new ContractState
{
Id = (int)json["id"].AsNumber(),
Hash = UInt160.Parse(json["hash"].AsString()),
Script = Convert.FromBase64String(json["script"].AsString()),
Manifest = ContractManifest.FromJson(json["manifest"])
};
Expand Down
117 changes: 50 additions & 67 deletions tests/Neo.Network.RPC.Tests/RpcTestCases.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,109 +318,87 @@
"Request": {
"jsonrpc": "2.0",
"method": "getcontractstate",
"params": [ "0x806b7fa0db3b46d6c42e1e1b0a7fd50db9d4a9b0" ],
"params": [ "0x36a019d836d964c438c573f78badf79b9e7eebdd" ],
"id": 1
},
"Response": {
"jsonrpc": "2.0",
"id": 1,
"result": {
"id": 0,
"hash": "0x806b7fa0db3b46d6c42e1e1b0a7fd50db9d4a9b0",
"script": "VgIMFGklqlVHEkOanGE7oRTvo/rCPdvKYAwDKiwKYVcDAiFB6X04oAwBINshmlCaULQlIwAAACEMFGklqlVHEkOanGE7oRTvo/rCPdvKIUH4J+yMQCFB6X04oAwBQNshmlCaULQlKQEAAHgMCWJhbGFuY2VPZpcnDwAAAHkQziE1WgEAAEB4DAhkZWNpbWFsc5cnDAAAACE1sQEAAEB4DAZkZXBsb3mXJwwAAAAhNbQBAABAeAwEbmFtZZcnDAAAACE1OQIAAEB4DAZzeW1ib2yXJwwAAAAhNTsCAABAeAwSc3VwcG9ydGVkU3RhbmRhcmRzlycMAAAAITUfAgAAQHgMC3R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AAAMCWVsc2UgcGFzcyFBz+dHliFBm/Znznl6IVNB5j8YhAwOYW1vdW50IC0+IHBhc3MhQc/nR5YheHl6IVMMCFRyYW5zZmVyFMBBlQFvYRFA",
"id": -2,
"updatecounter": 0,
"hash": "0x36a019d836d964c438c573f78badf79b9e7eebdd",
"script": "DANHQVNBa2d4Cw==",
"manifest": {
"name": "GAS",
"groups": [],
"features": {
"storage": true,
"payable": true
},
"supportedstandards": [
"NEP-5"
"NEP-17"
],
"abi": {
"hash": "0x806b7fa0db3b46d6c42e1e1b0a7fd50db9d4a9b0",
"methods": [
{
"name": "main",
"parameters": [
{
"name": "method",
"type": "String"
},
{
"name": "args",
"type": "Array"
}
],
"name": "onPersist",
"parameters": [],
"offset": 0,
"returntype": "ByteArray"
"returntype": "Void"
},
{
"name": "Destroy",
"name": "totalSupply",
"parameters": [],
"offset": 400,
"returntype": "Boolean"
"offset": 0,
"returntype": "Integer"
},
{
"name": "Migrate",
"name": "balanceOf",
"parameters": [
{
"name": "script",
"name": "account",
"type": "ByteArray"
},
{
"name": "manifest",
"type": "String"
}
],
"offset": 408,
"returntype": "Boolean"
"offset": 0,
"returntype": "Integer"
},
{
"name": "BalanceOf",
"name": "transfer",
"parameters": [
{
"name": "account",
"name": "from",
"type": "ByteArray"
},
{
"name": "to",
"type": "ByteArray"
},
{
"name": "amount",
"type": "Integer"
},
{
"name": "data",
"type": "Any"
}
],
"offset": 474,
"returntype": "Integer"
},
{
"name": "Decimals",
"parameters": [],
"offset": 585,
"returntype": "Integer"
},
{
"name": "Deploy",
"parameters": [],
"offset": 610,
"offset": 0,
"returntype": "Boolean"
},
{
"name": "Name",
"name": "postPersist",
"parameters": [],
"offset": 763,
"returntype": "String"
"offset": 0,
"returntype": "Void"
},
{
"name": "Symbol",
"name": "symbol",
"parameters": [],
"offset": 787,
"offset": 0,
"returntype": "String"
},
{
"name": "SupportedStandards",
"name": "decimals",
"parameters": [],
"offset": 793,
"returntype": "Array"
},
{
"name": "TotalSupply",
"parameters": [],
"offset": 827,
"offset": 0,
"returntype": "Integer"
}
],
Expand All @@ -429,15 +407,15 @@
"name": "Transfer",
"parameters": [
{
"name": "arg1",
"type": "ByteArray"
"name": "from",
"type": "Hash160"
},
{
"name": "arg2",
"type": "ByteArray"
"name": "to",
"type": "Hash160"
},
{
"name": "arg3",
"name": "amount",
"type": "Integer"
}
]
Expand All @@ -451,7 +429,12 @@
}
],
"trusts": [],
"safemethods": [],
"safemethods": [
"totalSupply",
"balanceOf",
"symbol",
"decimals"
],
"extra": null
}
}
Expand Down
2 changes: 0 additions & 2 deletions tests/Neo.Network.RPC.Tests/UT_ContractClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public async Task TestDeployContract()
Permissions = new[] { ContractPermission.DefaultPermission },
Abi = new ContractAbi()
{
Hash = new byte[1].ToScriptHash(),
Events = new ContractEventDescriptor[0],
Methods = new ContractMethodDescriptor[0]
},
Expand All @@ -55,7 +54,6 @@ public async Task TestDeployContract()
SupportedStandards = new string[] { "NEP-10" },
Extra = null,
};
manifest.Features = ContractFeatures.HasStorage | ContractFeatures.Payable;
using (ScriptBuilder sb = new ScriptBuilder())
{
sb.EmitSysCall(ApplicationEngine.System_Contract_Create, new byte[1], manifest.ToString());
Expand Down

0 comments on commit b522dce

Please sign in to comment.