Skip to content

Commit

Permalink
udpate neo (#1038)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim8y committed May 10, 2024
1 parent f346235 commit 160e8b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion neo
Submodule neo updated 134 files
8 changes: 4 additions & 4 deletions src/Neo.SmartContract.Testing/Native/NativeContracts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Block Initialize(bool commit = false)
{
// Mock Native.OnPersist

var method = native.GetType().GetMethod("OnPersist", BindingFlags.NonPublic | BindingFlags.Instance);
var method = native.GetType().GetMethod("OnPersistAsync", BindingFlags.NonPublic | BindingFlags.Instance);

DataCache clonedSnapshot = _engine.Storage.Snapshot.CreateSnapshot();
using (var engine = new TestingApplicationEngine(_engine, TriggerType.OnPersist, genesis, clonedSnapshot, genesis))
Expand All @@ -116,12 +116,12 @@ public Block Initialize(bool commit = false)

task.GetAwaiter().GetResult();
if (engine.Execute() != VM.VMState.HALT)
throw new Exception($"Error executing {native.Name}.OnPersist");
throw new Exception($"Error executing {native.Name}.OnPersistAsync");
}

// Mock Native.PostPersist

method = native.GetType().GetMethod("PostPersist", BindingFlags.NonPublic | BindingFlags.Instance);
method = native.GetType().GetMethod("PostPersistAsync", BindingFlags.NonPublic | BindingFlags.Instance);

using (var engine = new TestingApplicationEngine(_engine, TriggerType.PostPersist, genesis, clonedSnapshot, genesis))
{
Expand All @@ -131,7 +131,7 @@ public Block Initialize(bool commit = false)

task.GetAwaiter().GetResult();
if (engine.Execute() != VM.VMState.HALT)
throw new Exception($"Error executing {native.Name}.PostPersist");
throw new Exception($"Error executing {native.Name}.PostPersistAsync");
}

clonedSnapshot.Commit();
Expand Down
4 changes: 2 additions & 2 deletions tests/Neo.SmartContract.TestEngine/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ public static void DeployNativeContracts(this DataCache snapshot, Block? persist
{
persistingBlock ??= new NeoSystem(TestProtocolSettings.Default).GenesisBlock;

var method = typeof(SmartContract.Native.ContractManagement).GetMethod("OnPersist", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var method = typeof(SmartContract.Native.ContractManagement).GetMethod("OnPersistAsync", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
var engine = new TestEngine(TriggerType.OnPersist, null, snapshot, persistingBlock);
engine.LoadScript(Array.Empty<byte>());
method!.Invoke(SmartContract.Native.NativeContract.ContractManagement, new object[] { engine });
engine.Snapshot.Commit();

method = typeof(SmartContract.Native.LedgerContract).GetMethod("PostPersist", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
method = typeof(SmartContract.Native.LedgerContract).GetMethod("PostPersistAsync", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);
engine = new TestEngine(TriggerType.OnPersist, null, snapshot, persistingBlock);
engine.LoadScript(Array.Empty<byte>());
method!.Invoke(SmartContract.Native.NativeContract.Ledger, new object[] { engine });
Expand Down

0 comments on commit 160e8b7

Please sign in to comment.