"--build", action="store_true", help="build new contract ABIs") args = parser.parse_args() # start single-node local testnet eosf.reset() # create master account from which # other account can be created # accessed via global variable: master w = eosf.wallet.Wallet() eosf.create_master_account('master') # Create contract owner account: boid_token eosf.create_account('boid_token', master, account_name='boid.token') # acct1 does monthly stakes and acct2 does quarterly stakes eosf.create_account('acct1', master, account_name='account1') eosf.create_account('acct2', master, account_name='account2') accts = [acct1, acct2] # data frames to hold account state acct_df_columns = [ 'boid_power', 'staked_boid_tokens', 'unstaked_boid_tokens', 'total_boid_tokens' ] dfs = [ pd.DataFrame(columns=acct_df_columns), pd.DataFrame(columns=acct_df_columns) ]
def setUpClass(cls): eosf.SCENARIO(''' The ``master`` account sponsors the ``boid_token`` account that hosts the boidtoken contract and issues BOID tokens. There are ten test accounts ``accts``. We are testing the contract robustness to legal and illegal token staking scenarios. ''') testnet.verify_production() eosf.create_master_account("master", testnet) if arg_buy_ram > 0: master.buy_ram(arg_buy_ram) try: # Create contract owner account: boid_token eosf.create_account('boid_token', master, account_name='boidtoken123', buy_ram_kbytes=INITIAL_RAM_KBYTES, stake_net=INITIAL_STAKE_NET, stake_cpu=INITIAL_STAKE_CPU) except: pass for i in range(NUM_ACCOUNTS): eosf.create_account( 'acct{}'.format(i), master, ) test_accts.append(eval('acct{}'.format(i))) if not testnet.is_local(): cls.stats() contract = eosf.Contract(boid_token, CONTRACT_WORKSPACE) if arg_build: contract.build(force=False) try: contract.deploy(payer=master) except eosf.errors.ContractRunningError: pass # Set up boid_token account as issuer of BOID eosf.COMMENT(''' Attempting to create BOID token. This might fail if the BOID token has already been created: ''') try: boid_token.push_action( 'create', { 'issuer': boid_token, 'maximum_supply': '{:.4f} BOID'.format(MAX_BOID_SUPPLY) }, [boid_token]) except eosfactory.core.errors.Error as e: if "token already exists" in e.message: eosf.COMMENT(''' BOID token already exists ''') time.sleep(3) else: eosf.COMMENT(''' The error is different than expected. ''') raise Error(str(e)) stake_params = getStakeParams(contract.table('stakes', boid_token)) stakebreak(boid_token, boid_token, '1') for acct in test_accts: if acct.name in stake_params and\ float( stake_params[acct.name]['staked'].split()[0]) > 0: unstake(boid_token, acct, acct, 'memo') # Sleep to wait for next block to clear so we don't # accidentally have duplicate transactions time.sleep(1)
else: # start single-node local testnet eosf.reset() eosf.create_wallet() eosf.get_wallet().open_unlock() eosf.get_wallet().keys() # create master account from which # other account can be created # accessed via global variable: master eosf.create_master_account('master') # Create accounts: eosio_token, eos, boid, boid_stake, boid_power, acct1, acct2 eosf.create_account('eosio_token', master, account_name='eosio.token') eosf.create_account('eos', master, account_name='eos') eosf.create_account('boid', master, account_name='boid') eosf.create_account('boid_power', master, account_name='boid.power') eosf.create_account('boid_stake', master, account_name='boid.stake') # setAccountPermission( # boid_stake.name, 'xfer', # transferPermission( # '', #boid_stake.active_key.key_public, # boid_stake.name), 'active') # print(222222222) # print(boid_stake.name) # print(333333333) # EOS7nLRAheR7tYMiTiCA2ry2vW2Yh4LKoMUsxiE6YcxSCh2nS8tq4 # key = boid_stake.active_key.key_public
parser.add_argument("-b", "--build", action="store_true", help="build new contract abis") args = parser.parse_args() # start single-node local testnet eosf.reset() # create master account from which # other account can be created # accessed via global variable: master eosf.create_master_account('master') # Create 7 accounts: eosio_token, eos, boid, acct1, acct2, acct3, acct4 eosf.create_account('eosio_token', master, account_name='eosio.token') eosf.create_account('eos', master, account_name='eos') eosf.create_account('boid', master, account_name='boid') eosf.create_account('acct1', master, account_name='account1') eosf.create_account('acct2', master, account_name='account2') eosf.create_account('acct3', master, account_name='account3') eosf.create_account('acct4', master, account_name='account4') # make build directory if it does not exist build_dir = os.path.join(RAM_PAYER_EXCHANGE_CONTRACT_PATH, 'build') if not os.path.exists(build_dir): os.mkdir(build_dir) # create reference to the token staking contract eosioToken_c = eosf.Contract(eosio_token, RAM_PAYER_EXCHANGE_CONTRACT_PATH)