Skip to content

Commit

Permalink
Added more tests about owner and active authority
Browse files Browse the repository at this point in the history
  • Loading branch information
abitmore committed Aug 16, 2018
1 parent 9acc7a0 commit fbef6c2
Showing 1 changed file with 43 additions and 1 deletion.
44 changes: 43 additions & 1 deletion tests/tests/authority_tests.cpp
Expand Up @@ -1449,6 +1449,7 @@ BOOST_FIXTURE_TEST_CASE( parent_owner_test, database_fixture )
}

/// This test case reproduces https://github.com/bitshares/bitshares-core/issues/944
/// and https://github.com/bitshares/bitshares-core/issues/580
BOOST_FIXTURE_TEST_CASE( missing_owner_auth_test, database_fixture )
{
try
Expand Down Expand Up @@ -1493,16 +1494,57 @@ BOOST_FIXTURE_TEST_CASE( missing_owner_auth_test, database_fixture )
public_key_type alice_owner_pub( alice_owner_key.get_public_key() );
set_auth( alice_id, authority( 1, alice_active_pub, 1 ), authority( 1, alice_owner_pub, 1 ) );

// creating a transaction that needs owner permission
signed_transaction tx;
account_update_operation op;
op.account = alice_id;
op.owner = authority( 1, alice_active_pub, 1 );
tx.operations.push_back( op );

// https://github.com/bitshares/bitshares-core/issues/944
// not signed, should throw tx_missing_owner_auth
GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner ),
graphene::chain::tx_missing_owner_auth );

// signed with alice's active key, should throw tx_missing_owner_auth
sign( tx, alice_active_key );
GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner ),
graphene::chain::tx_missing_owner_auth );

// signed with alice's owner key, should not throw
tx.signatures.clear();
sign( tx, alice_owner_key );
tx.verify_authority( db.get_chain_id(), get_active, get_owner );

// signed with both alice's owner key and active key,
// it does not throw due to https://github.com/bitshares/bitshares-core/issues/580
sign( tx, alice_active_key );
tx.verify_authority( db.get_chain_id(), get_active, get_owner );

// creating a transaction that needs active permission
tx.signatures.clear();
tx.operations.clear();
op.owner.reset();
op.active = authority( 1, alice_owner_pub, 1 );
tx.operations.push_back( op );

// not signed, should throw tx_missing_active_auth
GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner ),
graphene::chain::tx_missing_active_auth );

// signed with alice's active key, should not throw
sign( tx, alice_active_key );
tx.verify_authority( db.get_chain_id(), get_active, get_owner );

// signed with alice's owner key, should not throw
tx.signatures.clear();
sign( tx, alice_owner_key );
tx.verify_authority( db.get_chain_id(), get_active, get_owner );

// signed with both alice's owner key and active key, should throw tx_irrelevant_sig
sign( tx, alice_active_key );
GRAPHENE_REQUIRE_THROW( tx.verify_authority( db.get_chain_id(), get_active, get_owner ),

This comment has been minimized.

Copy link
@jmjatlanta

jmjatlanta Aug 17, 2018

Contributor

I do not see how this situation is different than line 1521. One is expecting a throw and the other is not. How would both of these pass?

This comment has been minimized.

Copy link
@jmjatlanta

jmjatlanta Aug 17, 2018

Contributor

I see now. The code is clear (transaction requirements are different), I was not.

graphene::chain::tx_irrelevant_sig );

}
catch(fc::exception& e)
{
Expand Down

0 comments on commit fbef6c2

Please sign in to comment.