From 680df7e0f9b05df884b769d4084e1af840ce65b5 Mon Sep 17 00:00:00 2001 From: s2quake Date: Fri, 25 Oct 2024 15:55:40 +0900 Subject: [PATCH] test: Remove test code for GasTracer --- .../Action/ActionEvaluatorTest.cs | 124 ------------------ 1 file changed, 124 deletions(-) diff --git a/test/Libplanet.Tests/Action/ActionEvaluatorTest.cs b/test/Libplanet.Tests/Action/ActionEvaluatorTest.cs index 64d9d208c0..45b6569757 100644 --- a/test/Libplanet.Tests/Action/ActionEvaluatorTest.cs +++ b/test/Libplanet.Tests/Action/ActionEvaluatorTest.cs @@ -1343,130 +1343,6 @@ public void OrderTxsForEvaluation( .Select(tx => tx.Signer.ToString()))); } - [Fact] - public void EvaluateActionAndCollectFee() - { - var privateKey = new PrivateKey(); - var address = privateKey.Address; - Currency foo = Currency.Uncapped( - "FOO", - 18, - null - ); - - var freeGasAction = new UseGasAction() - { - GasUsage = 0, - Memo = "FREE", - MintValue = FungibleAssetValue.FromRawValue(foo, 10), - Receiver = address, - }; - - var payGasAction = new UseGasAction() - { - GasUsage = 1, - Memo = "CHARGE", - }; - - var store = new MemoryStore(); - var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( - policy: new BlockPolicy(), - actions: new[] { freeGasAction, }, - store: store, - stateStore: stateStore, - actionLoader: new SingleActionLoader(typeof(UseGasAction))); - var tx = Transaction.Create( - nonce: 0, - privateKey: privateKey, - genesisHash: chain.Genesis.Hash, - maxGasPrice: FungibleAssetValue.FromRawValue(foo, 1), - gasLimit: 3, - actions: new[] - { - payGasAction, - }.ToPlainValues()); - - chain.StageTransaction(tx); - var miner = new PrivateKey(); - Block block = chain.ProposeBlock(miner); - - var evaluations = chain.ActionEvaluator.Evaluate( - block, chain.GetNextStateRootHash((BlockHash)block.PreviousHash)); - - Assert.False(evaluations[0].InputContext.IsPolicyAction); - Assert.Single(evaluations); - Assert.Null(evaluations.Single().Exception); - Assert.Equal(2, GasTracer.GasAvailable); - Assert.Equal(1, GasTracer.GasUsed); - } - - [Fact] - public void EvaluateThrowingExceedGasLimit() - { - var privateKey = new PrivateKey(); - var address = privateKey.Address; - Currency foo = Currency.Uncapped( - "FOO", - 18, - null - ); - - var freeGasAction = new UseGasAction() - { - GasUsage = 0, - Memo = "FREE", - MintValue = FungibleAssetValue.FromRawValue(foo, 10), - Receiver = address, - }; - - var payGasAction = new UseGasAction() - { - GasUsage = 10, - Memo = "CHARGE", - }; - - var store = new MemoryStore(); - var stateStore = new TrieStateStore(new MemoryKeyValueStore()); - var chain = TestUtils.MakeBlockChain( - policy: new BlockPolicy(), - actions: new[] - { - freeGasAction, - }, - store: store, - stateStore: stateStore, - actionLoader: new SingleActionLoader(typeof(UseGasAction))); - var tx = Transaction.Create( - nonce: 0, - privateKey: privateKey, - genesisHash: chain.Genesis.Hash, - maxGasPrice: FungibleAssetValue.FromRawValue(foo, 1), - gasLimit: 5, - actions: new[] - { - payGasAction, - }.ToPlainValues()); - - chain.StageTransaction(tx); - var miner = new PrivateKey(); - Block block = chain.ProposeBlock(miner); - - var evaluations = chain.ActionEvaluator.Evaluate( - block, - chain.GetNextStateRootHash((BlockHash)block.PreviousHash)); - - Assert.False(evaluations[0].InputContext.IsPolicyAction); - Assert.Single(evaluations); - Assert.NotNull(evaluations.Single().Exception); - Assert.NotNull(evaluations.Single().Exception?.InnerException); - Assert.Equal( - typeof(GasLimitExceededException), - evaluations.Single().Exception?.InnerException?.GetType()); - Assert.Equal(0, GasTracer.GasAvailable); - Assert.Equal(5, GasTracer.GasUsed); - } - [Fact] public void GenerateRandomSeed() {