提交 7a4c6180 编写于 作者: M Matias Romeo

fix missing tests

上级 44db5a1b
......@@ -47,50 +47,6 @@ namespace eosiosystem {
if( timestamp.slot - _gstate.last_producer_schedule_update.slot > 120 ) {
update_elected_producers( timestamp );
}
}
eosio::asset system_contract::payment_per_vote( const account_name& owner, double owners_votes, const eosio::asset& pervote_bucket ) {
eosio::asset payment(0, S(4,SYS));
const int64_t min_daily_amount = 100 * 10000;
if ( pervote_bucket.amount < min_daily_amount ) {
return payment;
}
auto idx = _producers.template get_index<N(prototalvote)>();
double total_producer_votes = 0;
double running_payment_amount = 0;
bool to_be_payed = false;
for ( auto itr = idx.cbegin(); itr != idx.cend(); ++itr ) {
if ( !(itr->total_votes > 0) ) {
break;
}
if ( !itr->active() ) {
continue;
}
if ( itr->owner == owner ) {
to_be_payed = true;
}
total_producer_votes += itr->total_votes;
running_payment_amount = (itr->total_votes) * double(pervote_bucket.amount) / total_producer_votes;
if ( running_payment_amount < min_daily_amount ) {
if ( itr->owner == owner ) {
to_be_payed = false;
}
total_producer_votes -= itr->total_votes;
break;
}
}
if ( to_be_payed ) {
payment.amount = static_cast<int64_t>( (double(pervote_bucket.amount) * owners_votes) / total_producer_votes );
}
return payment;
}
using namespace eosio;
......
......@@ -255,7 +255,7 @@ try:
if not node.verifyAccount(testeraAccount):
errorExit("FAILURE - account creation failed.", raw=True)
transferAmount="97.5321 EOS"
transferAmount="97.5321 SYS"
Print("Transfer funds %s from account %s to %s" % (transferAmount, defproduceraAccount.name, testeraAccount.name))
if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer") is None:
cmdError("%s transfer" % (ClientName))
......@@ -269,7 +269,7 @@ try:
cmdError("FAILURE - transfer failed")
errorExit("Transfer verification failed. Excepted %s, actual: %s" % (expectedAmount, actualAmount))
transferAmount="0.0100 EOS"
transferAmount="0.0100 SYS"
Print("Force transfer funds %s from account %s to %s" % (
transferAmount, defproduceraAccount.name, testeraAccount.name))
if node.transferFunds(defproduceraAccount, testeraAccount, transferAmount, "test transfer", force=True) is None:
......@@ -277,7 +277,7 @@ try:
errorExit("Failed to force transfer funds %d from account %s to %s" % (
transferAmount, defproduceraAccount.name, testeraAccount.name))
expectedAmount="97.5421 EOS"
expectedAmount="97.5421 SYS"
Print("Verify transfer, Expected: %s" % (expectedAmount))
actualAmount=node.getAccountEosBalanceStr(testeraAccount.name)
if expectedAmount != actualAmount:
......@@ -298,7 +298,7 @@ try:
cmdError("%s wallet unlock" % (ClientName))
errorExit("Failed to unlock wallet %s" % (testWallet.name))
transferAmount="97.5311 EOS"
transferAmount="97.5311 SYS"
Print("Transfer funds %s from account %s to %s" % (
transferAmount, testeraAccount.name, currencyAccount.name))
trans=node.transferFunds(testeraAccount, currencyAccount, transferAmount, "test transfer a->b")
......@@ -308,7 +308,7 @@ try:
transferAmount, testeraAccount.name, currencyAccount.name))
transId=testUtils.Node.getTransId(trans)
expectedAmount="98.0311 EOS" # 5000 initial deposit
expectedAmount="98.0311 SYS" # 5000 initial deposit
Print("Verify transfer, Expected: %s" % (expectedAmount))
actualAmount=node.getAccountEosBalanceStr(currencyAccount.name)
if expectedAmount != actualAmount:
......
......@@ -50,7 +50,7 @@ class StressNetwork:
print("issue currency0000 into %s" % (acc1.name))
contract="eosio"
action="issue"
data="{\"to\":\"" + acc1.name + "\",\"quantity\":\"1000000.0000 EOS\"}"
data="{\"to\":\"" + acc1.name + "\",\"quantity\":\"1000000.0000 SYS\"}"
opts="--permission eosio@active"
tr=node.pushMessage(contract, action, data, opts)
trid = node.getTransId(tr[1])
......
......@@ -537,7 +537,7 @@ class Node(object):
# Create & initialize account and return creation transactions. Return transaction json object
def createInitializeAccount(self, account, creatorAccount, stakedDeposit=1000, waitForTransBlock=False):
cmd='%s %s system newaccount -j %s %s %s %s --stake-net "100 EOS" --stake-cpu "100 EOS" --buy-ram-EOS "100 EOS"' % (
cmd='%s %s system newaccount -j %s %s %s %s --stake-net "100 SYS" --stake-cpu "100 SYS" --buy-ram-EOS "100 SYS"' % (
Utils.EosClientPath, self.endpointArgs, creatorAccount.name, account.name,
account.ownerPublicKey, account.activePublicKey)
......@@ -553,7 +553,7 @@ class Node(object):
if stakedDeposit > 0:
self.waitForTransIdOnNode(transId) # seems like account creation needs to be finlized before transfer can happen
trans = self.transferFunds(creatorAccount, account, "%0.04f EOS" % (stakedDeposit/10000), "init")
trans = self.transferFunds(creatorAccount, account, "%0.04f SYS" % (stakedDeposit/10000), "init")
transId=Node.getTransId(trans)
if waitForTransBlock and not self.waitForTransIdOnNode(transId):
......@@ -580,7 +580,7 @@ class Node(object):
if stakedDeposit > 0:
self.waitForTransIdOnNode(transId) # seems like account creation needs to be finlized before transfer can happen
trans = self.transferFunds(creatorAccount, account, "%0.04f EOS" % (stakedDeposit/10000), "init")
trans = self.transferFunds(creatorAccount, account, "%0.04f SYS" % (stakedDeposit/10000), "init")
transId=Node.getTransId(trans)
if waitForTransBlock and not self.waitForTransIdOnNode(transId):
......@@ -786,7 +786,7 @@ class Node(object):
return servants
def getAccountEosBalanceStr(self, scope):
"""Returns EOS currency0000 account balance from cleos get table command. Returned balance is string following syntax "98.0311 EOS". """
"""Returns EOS currency0000 account balance from cleos get table command. Returned balance is string following syntax "98.0311 SYS". """
assert isinstance(scope, str)
if not self.enableMongo:
amount=self.getNodeAccountBalance("eosio.token", scope)
......@@ -1927,7 +1927,7 @@ class Cluster(object):
contract=eosioTokenAccount.name
Utils.Print("push create action to %s contract" % (contract))
action="create"
data="{\"issuer\":\"%s\",\"maximum_supply\":\"1000000000.0000 EOS\",\"can_freeze\":\"0\",\"can_recall\":\"0\",\"can_whitelist\":\"0\"}" % (eosioTokenAccount.name)
data="{\"issuer\":\"%s\",\"maximum_supply\":\"1000000000.0000 SYS\",\"can_freeze\":\"0\",\"can_recall\":\"0\",\"can_whitelist\":\"0\"}" % (eosioTokenAccount.name)
opts="--permission %s@active" % (contract)
trans=biosNode.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
......@@ -1941,7 +1941,7 @@ class Cluster(object):
contract=eosioTokenAccount.name
Utils.Print("push issue action to %s contract" % (contract))
action="issue"
data="{\"to\":\"%s\",\"quantity\":\"1000000000.0000 EOS\",\"memo\":\"initial issue\"}" % (eosioAccount.name)
data="{\"to\":\"%s\",\"quantity\":\"1000000000.0000 SYS\",\"memo\":\"initial issue\"}" % (eosioAccount.name)
opts="--permission %s@active" % (contract)
trans=biosNode.pushMessage(contract, action, data, opts)
if trans is None or not trans[0]:
......@@ -1953,7 +1953,7 @@ class Cluster(object):
transId=Node.getTransId(trans[1])
biosNode.waitForTransIdOnNode(transId)
expectedAmount="1000000000.0000 EOS"
expectedAmount="1000000000.0000 SYS"
Utils.Print("Verify eosio issue, Expected: %s" % (expectedAmount))
actualAmount=biosNode.getAccountEosBalanceStr(eosioAccount.name)
if expectedAmount != actualAmount:
......@@ -1973,7 +1973,7 @@ class Cluster(object):
Node.validateTransaction(trans)
initialFunds="1000000.0000 EOS"
initialFunds="1000000.0000 SYS"
Utils.Print("Transfer initial fund %s to individual accounts." % (initialFunds))
trans=None
contract=eosioTokenAccount.name
......
......@@ -1900,7 +1900,7 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester)
abi_serializer msig_abi_ser;
{
create_account_with_resources( N(eosio.msig), N(eosio) );
BOOST_REQUIRE_EQUAL( success(), buyram( "eosio", "eosio.msig", "5000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL( success(), buyram( "eosio", "eosio.msig", "5000.0000 SYS" ) );
produce_block();
auto trace = base_tester::push_action(config::system_account_name, N(setpriv),
......@@ -1920,8 +1920,8 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester)
}
//stake more than 15% of total EOS supply to activate chain
transfer( "eosio", "alice1111111", "650000000.0000 EOS", "eosio" );
BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "alice1111111", "300000000.0000 EOS", "300000000.0000 EOS" ) );
transfer( "eosio", "alice1111111", "650000000.0000 SYS", "eosio" );
BOOST_REQUIRE_EQUAL( success(), stake( "alice1111111", "alice1111111", "300000000.0000 SYS", "300000000.0000 SYS" ) );
// create accounts {defproducera, defproducerb, ..., defproducerz} and register as producers
std::vector<account_name> producer_names;
......@@ -1955,9 +1955,9 @@ BOOST_FIXTURE_TEST_CASE(producers_upgrade_system_contract, eosio_system_tester)
//vote for producers
{
transfer( config::system_account_name, "alice1111111", "100000000.0000 EOS", config::system_account_name );
BOOST_REQUIRE_EQUAL(success(), stake( "alice1111111", "30000000.0000 EOS", "30000000.0000 EOS" ) );
BOOST_REQUIRE_EQUAL(success(), buyram( "alice1111111", "alice1111111", "30000000.0000 EOS" ) );
transfer( config::system_account_name, "alice1111111", "100000000.0000 SYS", config::system_account_name );
BOOST_REQUIRE_EQUAL(success(), stake( "alice1111111", "30000000.0000 SYS", "30000000.0000 SYS" ) );
BOOST_REQUIRE_EQUAL(success(), buyram( "alice1111111", "alice1111111", "30000000.0000 SYS" ) );
BOOST_REQUIRE_EQUAL(success(), push_action(N(alice1111111), N(voteproducer), mvo()
("voter", "alice1111111")
("proxy", name(0).to_string())
......
......@@ -53,7 +53,7 @@ public:
}
transaction_trace_ptr create_account_with_resources( account_name a, account_name creator, asset ramfunds, bool multisig,
asset net = asset::from_string("10.0000 EOS"), asset cpu = asset::from_string("10.0000 EOS") ) {
asset net = asset::from_string("10.0000 SYS"), asset cpu = asset::from_string("10.0000 SYS") ) {
signed_transaction trx;
set_transaction_headers(trx);
......@@ -129,14 +129,14 @@ public:
// the balance is implied to be 0 if either the table or row does not exist
if (tbl) {
const auto *obj = db.find<key_value_object, by_scope_primary>(boost::make_tuple(tbl->id, symbol(SY(4,EOS)).to_symbol_code()));
const auto *obj = db.find<key_value_object, by_scope_primary>(boost::make_tuple(tbl->id, symbol(SY(4,SYS)).to_symbol_code()));
if (obj) {
// balance is the first field in the serialization
fc::datastream<const char *> ds(obj->value.data(), obj->value.size());
fc::raw::unpack(ds, result);
}
}
return asset( result, symbol(SY(4,EOS)) );
return asset( result, symbol(SY(4,SYS)) );
}
transaction_trace_ptr push_action( const account_name& signer, const action_name& name, const variant_object& data, bool auth = true ) {
......@@ -421,20 +421,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
set_code( N(eosio.token), eosio_token_wast );
set_abi( N(eosio.token), eosio_token_abi );
create_currency( N(eosio.token), config::system_account_name, asset::from_string("10000000000.0000 EOS") );
issue(config::system_account_name, "1000000000.0000 EOS");
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) );
create_currency( N(eosio.token), config::system_account_name, asset::from_string("10000000000.0000 SYS") );
issue(config::system_account_name, "1000000000.0000 SYS");
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
set_code( config::system_account_name, eosio_system_wast );
set_abi( config::system_account_name, eosio_system_abi );
produce_blocks();
create_account_with_resources( N(alice1111111), N(eosio), asset::from_string("1.0000 EOS"), false );
create_account_with_resources( N(bob111111111), N(eosio), asset::from_string("0.4500 EOS"), false );
create_account_with_resources( N(carol1111111), N(eosio), asset::from_string("1.0000 EOS"), false );
create_account_with_resources( N(alice1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
create_account_with_resources( N(bob111111111), N(eosio), asset::from_string("0.4500 SYS"), false );
create_account_with_resources( N(carol1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) );
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name} };
......@@ -508,7 +508,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_all_approve, eosio_msig_tester )
BOOST_REQUIRE_EQUAL( transaction_receipt::executed, trace->receipt->status );
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), asset::from_string("1.0000 EOS"), false ),
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), asset::from_string("1.0000 SYS"), false ),
fc::assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "condition: assertion failed: Unknown Test");
......@@ -532,20 +532,20 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
set_code( N(eosio.token), eosio_token_wast );
set_abi( N(eosio.token), eosio_token_abi );
create_currency( N(eosio.token), config::system_account_name, asset::from_string("10000000000.0000 EOS") );
issue(config::system_account_name, "1000000000.0000 EOS");
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) );
create_currency( N(eosio.token), config::system_account_name, asset::from_string("10000000000.0000 SYS") );
issue(config::system_account_name, "1000000000.0000 SYS");
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
set_code( config::system_account_name, eosio_system_wast );
set_abi( config::system_account_name, eosio_system_abi );
produce_blocks();
create_account_with_resources( N(alice1111111), N(eosio), asset::from_string("1.0000 EOS"), false );
create_account_with_resources( N(bob111111111), N(eosio), asset::from_string("0.4500 EOS"), false );
create_account_with_resources( N(carol1111111), N(eosio), asset::from_string("1.0000 EOS"), false );
create_account_with_resources( N(alice1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
create_account_with_resources( N(bob111111111), N(eosio), asset::from_string("0.4500 SYS"), false );
create_account_with_resources( N(carol1111111), N(eosio), asset::from_string("1.0000 SYS"), false );
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 EOS"), get_balance( "eosio" ) );
BOOST_REQUIRE_EQUAL( asset::from_string("1000000000.0000 SYS"), get_balance( "eosio" ) );
vector<permission_level> perm = { { N(alice), config::active_name }, { N(bob), config::active_name },
{N(carol), config::active_name}, {N(apple), config::active_name}};
......@@ -634,7 +634,7 @@ BOOST_FIXTURE_TEST_CASE( update_system_contract_major_approve, eosio_msig_tester
BOOST_REQUIRE_EQUAL( transaction_receipt::executed, trace->receipt->status );
// can't create account because system contract was replace by the test_api contract
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), asset::from_string("1.0000 EOS"), false ),
BOOST_REQUIRE_EXCEPTION(create_account_with_resources( N(alice1111112), N(eosio), asset::from_string("1.0000 SYS"), false ),
fc::assert_exception,
[](const fc::exception& e) {
return expect_assert_message(e, "condition: assertion failed: Unknown Test");
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册