Skip to content

Commit

Permalink
test: Fix StageTransaction test
Browse files Browse the repository at this point in the history
  • Loading branch information
OnedgeLee committed Jul 2, 2024
1 parent 83ee4df commit e5f31ee
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions NineChronicles.Headless.Tests/GraphTypes/StandaloneMutationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -903,14 +903,31 @@ public async Task StageTransaction()
StandaloneContextFx.BlockChain = service.Swarm?.BlockChain;

var pk = new PrivateKey();
ActionBase action = new ApprovePledge
ActionBase patronPrepareAction = new PrepareRewardAssets
{
PatronAddress = new PrivateKey().Address
RewardPoolAddress = MeadConfig.PatronAddress,
Assets = new List<FungibleAssetValue>
{
1 * Currencies.Mead,
},
};
var tx = Transaction.Create(0, pk, BlockChain.Genesis.Hash, new[] { action.PlainValue });
var tx = Transaction.Create(0, pk, BlockChain.Genesis.Hash, new[] { patronPrepareAction.PlainValue });
var payload = ByteUtil.Hex(tx.Serialize());
var stageTxMutation = $"mutation {{ stageTransaction(payload: \"{payload}\") }}";
var stageTxResult = await ExecuteQueryAsync(stageTxMutation);
Assert.Null(stageTxResult.Errors);

var block = service.BlockChain.ProposeBlock(ProposerPrivateKey, null);
service.BlockChain.Append(block, GenerateBlockCommit(1, block.Hash, new List<PrivateKey>() { ProposerPrivateKey }));

ActionBase action = new ApprovePledge
{
PatronAddress = new PrivateKey().Address
};
tx = Transaction.Create(0, pk, BlockChain.Genesis.Hash, new[] { action.PlainValue });
payload = ByteUtil.Hex(tx.Serialize());
stageTxMutation = $"mutation {{ stageTransaction(payload: \"{payload}\") }}";
stageTxResult = await ExecuteQueryAsync(stageTxMutation);
var error = Assert.Single(stageTxResult.Errors!);
Assert.Contains("gas", error.Message);
}
Expand Down

0 comments on commit e5f31ee

Please sign in to comment.