Skip to content

Commit

Permalink
SmartContract: refactor obsolete code
Browse files Browse the repository at this point in the history
Signed-off-by: Anna Shaleva <[email protected]>
  • Loading branch information
AnnaShaleva committed Jan 23, 2025
1 parent 4af93c8 commit ec4e3d6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Neo/SmartContract/Native/GasToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ internal override async ContractTask OnPersistAsync(ApplicationEngine engine)
var notaryAssisted = tx.GetAttribute<NotaryAssisted>();
if (notaryAssisted is not null)
{
totalNetworkFee -= (notaryAssisted.NKeys + 1) * Policy.GetAttributeFee(engine.Snapshot, (byte)notaryAssisted.Type);
totalNetworkFee -= (notaryAssisted.NKeys + 1) * Policy.GetAttributeFee(engine.SnapshotCache, (byte)notaryAssisted.Type);
}
}
ECPoint[] validators = NEO.GetNextBlockValidators(engine.SnapshotCache, engine.ProtocolSettings.ValidatorsCount);
Expand Down
2 changes: 1 addition & 1 deletion src/Neo/SmartContract/Native/PolicyContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ internal override ContractTask InitializeAsync(ApplicationEngine engine, Hardfor
}
if (hardfork == Hardfork.HF_Echidna)
{
engine.Snapshot.Add(CreateStorageKey(Prefix_AttributeFee).Add((byte)TransactionAttributeType.NotaryAssisted), new StorageItem(DefaultNotaryAssistedAttributeFee));
engine.SnapshotCache.Add(CreateStorageKey(Prefix_AttributeFee).Add((byte)TransactionAttributeType.NotaryAssisted), new StorageItem(DefaultNotaryAssistedAttributeFee));
}
return ContractTask.CompletedTask;
}
Expand Down
16 changes: 3 additions & 13 deletions tests/Neo.UnitTests/SmartContract/Native/UT_GasToken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,15 @@
using Neo.Extensions;
using Neo.IO;
using Neo.Network.P2P.Payloads;
using Neo.Network.P2P.Payloads;
using Neo.Persistence;
using Neo.Persistence;
using Neo.SmartContract;
using Neo.SmartContract;
using Neo.SmartContract.Native;
using Neo.SmartContract.Native;
using Neo.UnitTests.Extensions;
using Neo.UnitTests.Extensions;
using Neo.VM;
using Neo.Wallets;
using System;
using System;
using System;
using System.Linq;
using System.Linq;
using System.Numerics;
using System.Numerics;
using System.Numerics;
using System.Threading.Tasks;
using VMTypes = Neo.VM.Types;
// using VMArray = Neo.VM.Types.Array;
Expand Down Expand Up @@ -209,9 +199,9 @@ public void Check_OnPersist_NotaryAssisted()
var engine = ApplicationEngine.Create(TriggerType.OnPersist, null, snapshot, persistingBlock, settings: TestBlockchain.TheNeoSystem.Settings);

// Check that block's Primary balance is 0.
ECPoint[] validators = NativeContract.NEO.GetNextBlockValidators(engine.Snapshot, engine.ProtocolSettings.ValidatorsCount);
ECPoint[] validators = NativeContract.NEO.GetNextBlockValidators(engine.SnapshotCache, engine.ProtocolSettings.ValidatorsCount);
var primary = Contract.CreateSignatureRedeemScript(validators[engine.PersistingBlock.PrimaryIndex]).ToScriptHash();
NativeContract.GAS.BalanceOf(engine.Snapshot, primary).Should().Be(0);
NativeContract.GAS.BalanceOf(engine.SnapshotCache, primary).Should().Be(0);

// Execute OnPersist script.
engine.LoadScript(script.ToArray());
Expand All @@ -221,7 +211,7 @@ public void Check_OnPersist_NotaryAssisted()
// will be minted to Notary nodes as a reward once Notary contract is implemented.
Assert.AreEqual(2 + 1, engine.Notifications.Count()); // burn tx1 and tx2 network fee + mint primary reward
Assert.AreEqual(netFee1 + netFee2 - expectedNotaryReward, engine.Notifications[2].State[2]);
NativeContract.GAS.BalanceOf(engine.Snapshot, primary).Should().Be(netFee1 + netFee2 - expectedNotaryReward);
NativeContract.GAS.BalanceOf(engine.SnapshotCache, primary).Should().Be(netFee1 + netFee2 - expectedNotaryReward);
}
}
}

0 comments on commit ec4e3d6

Please sign in to comment.