提交 94f22681 编写于 作者: N Nathan Hourt

Ref #123: More testing

Test that a fully validated transaction to transfer money requires the
linked authority, or a parent, but not a child.
上级 c69cd8df
......@@ -166,7 +166,7 @@ types::PublicKey testing_blockchain::get_block_signing_key(const types::AccountN
return get_database().get<producer_object, by_owner>(producerName).signing_key;
}
void testing_blockchain::sign_transaction(SignedTransaction& trx) {
void testing_blockchain::sign_transaction(SignedTransaction& trx) const {
auto GetAuthority = [this](const types::AccountPermission& permission) {
auto key = boost::make_tuple(permission.account, permission.permission);
return db.get<permission_object, by_owner>(key).auth;
......
......@@ -180,7 +180,7 @@ public:
PublicKey get_block_signing_key(const AccountName& producerName);
/// @brief Attempt to sign the provided transaction using the keys available to the testing_fixture
void sign_transaction(SignedTransaction& trx);
void sign_transaction(SignedTransaction& trx) const;
/// @brief Override push_transaction to apply testing policies
/// If transactions are being held for review, transaction will be held after testing policies are applied
......
......@@ -483,6 +483,7 @@ BOOST_FIXTURE_TEST_CASE(auth_tests, testing_fixture) {
BOOST_FIXTURE_TEST_CASE(auth_links, testing_fixture) { try {
Make_Blockchain(chain);
Make_Account(chain, alice);
Make_Account(chain, bob);
chain.produce_blocks();
Make_Key(spending);
......@@ -506,6 +507,35 @@ BOOST_FIXTURE_TEST_CASE(auth_links, testing_fixture) { try {
BOOST_CHECK_EQUAL(obj->message_type, "transfer");
}
Transfer_Asset(chain, inita, alice, Asset(1000));
chain.set_auto_sign_transactions(false);
chain.set_skip_transaction_signature_checking(false);
chain.set_hold_transactions_for_review(true);
Transfer_Asset(chain, alice, bob, Asset(10));
BOOST_CHECK_THROW(chain.review_transaction([&chain](SignedTransaction& trx, auto) {
trx.messages.front().authorization = {{"alice", "scud"}};
chain.sign_transaction(trx);
return true;
}), tx_irrelevant_auth);
chain.review_transaction([&chain](SignedTransaction& trx, auto) {
trx.messages.front().authorization = {{"alice", "spending"}};
trx.signatures.clear();
chain.sign_transaction(trx);
return true;
});
chain.review_transaction([&chain](SignedTransaction& trx, auto) {
trx.messages.front().authorization = {{"alice", "active"}};
trx.signatures.clear();
chain.sign_transaction(trx);
return true;
});
BOOST_CHECK_EQUAL(chain.get_liquid_balance("bob"), Asset(20));
chain.set_skip_transaction_signature_checking(true);
chain.set_hold_transactions_for_review(false);
Unlink_Authority(chain, alice, eos, "transfer");
BOOST_CHECK_NE(
(chain_db.find<permission_link_object, by_message_type>(boost::make_tuple("alice", "eos", "transfer"))),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册