Skip to content

Commit

Permalink
Merge pull request #3972 from hpatel292-seneca/issue-3781
Browse files Browse the repository at this point in the history
Update ProposeGenesis in TestUtils to remove redundant Initialize()
  • Loading branch information
OnedgeLee authored Oct 18, 2024
2 parents 493f65b + ef139b6 commit 68d8f42
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion test/Libplanet.Net.Tests/Messages/MessageTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void GetId()
var message = new BlockHeaderMsg(genesis.Hash, genesis.Header);
Assert.Equal(
new MessageId(ByteUtil.ParseHex(
"1aa2c8fad502f8890b2e8cf6f9afe57e6f718f454f14f8304165e921b28905bf")),
"1d4296f8e28bfc873a5e72cbbd17454d7cf2dbee86c2481e4876e236f8ae2dee")),
message.Id);
}

Expand Down
6 changes: 3 additions & 3 deletions test/Libplanet.Tests/Action/ActionEvaluatorTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -596,9 +596,9 @@ DumbAction MakeAction(Address address, char identifier, Address? transferTo = nu
// have to be updated, since the order may change due to different PreEvaluationHash.
expectations = new (int TxIdx, int ActionIdx, string[] UpdatedStates, Address Signer)[]
{
(2, 0, new[] { "A", "B", "C", null, "F" }, _txFx.Address3),
(1, 0, new[] { "A", "B", "C", "E", "F" }, _txFx.Address2),
(0, 0, new[] { "A,D", "B", "C", "E", "F" }, _txFx.Address1),
(1, 0, new[] { "A", "B", "C", "E", null }, _txFx.Address2),
(0, 0, new[] { "A,D", "B", "C", "E", null }, _txFx.Address1),
(2, 0, new[] { "A,D", "B", "C", "E", "F" }, _txFx.Address3),
};
Assert.Equal(expectations.Length, evals.Length);
foreach (var (expect, eval) in expectations.Zip(evals, (x, y) => (x, y)))
Expand Down
25 changes: 12 additions & 13 deletions test/Libplanet.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -422,19 +422,18 @@ public static PreEvaluationBlock ProposeGenesis(
var txs = transactions?.ToList() ?? new List<Transaction>();
long nonce = 0;
validatorSet = validatorSet ?? ValidatorSet;
txs.AddRange(
validatorSet.Validators.Select(
validator => Transaction.Create(
nonce++,
GenesisProposer,
null,
actions: new IAction[]
{
new Initialize(
validatorSet: validatorSet,
states: ImmutableDictionary.Create<Address, IValue>()),
}.Select(x => x.PlainValue),
timestamp: DateTimeOffset.MinValue)));
txs.Add(
Transaction.Create(
nonce++,
GenesisProposer,
null,
actions: new IAction[]
{
new Initialize(
validatorSet: validatorSet,
states: ImmutableDictionary.Create<Address, IValue>()),
}.Select(x => x.PlainValue),
timestamp: DateTimeOffset.MinValue));
txs = txs.OrderBy(tx => tx.Id).ToList();

var content = new BlockContent(
Expand Down

0 comments on commit 68d8f42

Please sign in to comment.