Skip to content

Commit

Permalink
Add explicit negative-test for state block signature checking
Browse files Browse the repository at this point in the history
  • Loading branch information
clemahieu committed Oct 19, 2023
1 parent 2c678c0 commit 69bba0c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions nano/core_test/ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1240,6 +1240,28 @@ TEST (ledger, fail_change_gap_previous)
ASSERT_EQ (nano::process_result::gap_previous, result1.code);
}

TEST (ledger, fail_state_bad_signature)
{
auto ctx = nano::test::context::ledger_empty ();
auto & ledger = ctx.ledger ();
auto & store = ctx.store ();
auto transaction = store.tx_begin_write ();
nano::work_pool pool{ nano::dev::network_params.network, std::numeric_limits<unsigned>::max () };
nano::block_builder builder;
auto block = builder
.state ()
.account (nano::dev::genesis_key.pub)
.previous (nano::dev::genesis->hash ())
.representative (nano::dev::genesis_key.pub)
.balance (0)
.link (nano::dev::genesis_key.pub)
.sign (nano::keypair ().prv, 0)
.work (*pool.generate (nano::dev::genesis->hash ()))
.build ();
auto result1 = ledger.process (transaction, *block);
ASSERT_EQ (nano::process_result::bad_signature, result1.code);
}

TEST (ledger, fail_change_bad_signature)
{
auto ctx = nano::test::context::ledger_empty ();
Expand Down

0 comments on commit 69bba0c

Please sign in to comment.