Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhitong committed Jun 24, 2024
1 parent 90468e8 commit d425281
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,10 @@
<ProjectReference Include="..\..\src\Plugins\RocksDBStore\RocksDBStore.csproj" />
</ItemGroup>

<ItemGroup>
<None Update="libleveldb.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

</Project>
Binary file added tests/Neo.Plugins.Storage.Tests/libleveldb.dll
Binary file not shown.
36 changes: 36 additions & 0 deletions tests/Neo.UnitTests/SmartContract/UT_InteropService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
// modifications are permitted.

using Akka.TestKit.Xunit2;
using Akka.Util.Internal;
using FluentAssertions;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Neo.Cryptography;
Expand Down Expand Up @@ -507,6 +508,41 @@ public void TestBlockchain_GetContract()
NativeContract.ContractManagement.GetContract(engine.Snapshot, state.Hash).Hash.Should().Be(state.Hash);
}

[TestMethod]
public void TestBlockchain_GetContractById()
{
var engine = GetEngine(true, true);
var contract = NativeContract.ContractManagement.GetContractById(engine.Snapshot, -1);
contract.Id.Should().Be(-1);
contract.Manifest.Name.Should().Be(nameof(ContractManagement));
}

[TestMethod]
public void TestBlockchain_HasMethod()
{
var engine = GetEngine(true, true);
NativeContract.ContractManagement.HasMethod(engine.Snapshot, NativeContract.NEO.Hash, "symbol", 0).Should().Be(true);
NativeContract.ContractManagement.HasMethod(engine.Snapshot, NativeContract.NEO.Hash, "transfer", 4).Should().Be(true);
}

[TestMethod]
public void TestBlockchain_ListContracts()
{
var engine = GetEngine(true, true);
var list = NativeContract.ContractManagement.ListContracts(engine.Snapshot);
list.ForEach(p => p.Id.Should().BeLessThan(0));

var snapshot = TestBlockchain.GetTestSnapshot();
var state = TestUtils.GetContract();
snapshot.AddContract(state.Hash, state);
engine = ApplicationEngine.Create(TriggerType.Application, null, snapshot);
engine.LoadScript(new byte[] { 0x01 });
NativeContract.ContractManagement.GetContract(engine.Snapshot, state.Hash).Hash.Should().Be(state.Hash);

var list2 = NativeContract.ContractManagement.ListContracts(engine.Snapshot);
list2.Count().Should().Be(list.Count() + 1);
}

[TestMethod]
public void TestStorage_GetContext()
{
Expand Down

0 comments on commit d425281

Please sign in to comment.