nargs=4,
                        help="<url> <name> <owner key> <active key>")

    parser.add_argument("-b",
                        "--build",
                        action="store_true",
                        help="build new contract ABIs")

    args = parser.parse_args()

    testnet = get_testnet(args.alias, args.testnet)
    testnet.configure()

    ################ test begins here #################

    eosf.create_master_account('master')

    # make build directory if it does not exist
    build_dir = os.path.join(BOID_TOKEN_CONTRACT_PATH, 'build')
    if not os.path.exists(build_dir):
        os.mkdir(build_dir)

    # create reference to the token staking contract
    # build and deploy the contracts on the testnet
    contract = eosf.Contract(master, BOID_TOKEN_CONTRACT_PATH)
    if args.build:
        contract.build()
    contract.deploy()

    balance = getBalance(contract.table("accounts", master))
    print('master balance')
예제 #2
0
    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)