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')
    print(balance)

    balance = getBalance(contract.table("accounts", alice))
    print('alice balance')
    print(balance)

    stake_params = getStakeParams(contract.table('stakes', master))
    print('stake_params')
    print(stake_params)
Ejemplo n.º 2
0
        'boid_power', 'staked_boid_tokens', 'unstaked_boid_tokens',
        'total_boid_tokens'
    ]
    dfs = [
        pd.DataFrame(columns=acct_df_columns),
        pd.DataFrame(columns=acct_df_columns)
    ]

    # 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
    boidToken_c = eosf.Contract(boid_token, BOID_TOKEN_CONTRACT_PATH)
    #if args.build:
    boidToken_c.build()
    boidToken_c.deploy()

    ############# now we can call functions ##############
    ########## (aka actions) from the contract! ##########

    # Set up boid_token account as issuer of BOID
    boidToken_c.push_action('create', {
        'issuer': boid_token,
        'maximum_supply': '1000000000.0000 BOID'
    }, [boid_token])

    # issue tokens to accts
    for acct in accts:
Ejemplo n.º 3
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)
Ejemplo n.º 4
0
            'staked_boid_tokens',
            'unstaked_boid_tokens',
            'total_boid_tokens']
        dfs = [
            pd.DataFrame(columns=acct_df_columns),
            pd.DataFrame(columns=acct_df_columns)]

        # make build directory if it does not exist
        # (so eosfactory sets up the eos contract proberly)
        build_dir = os.path.join(BOID_STAKE_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
        eosioToken_c = eosf.Contract(eosio_token, EOS_TOKEN_CONTRACT_PATH)
        boidStake_c  = eosf.Contract(boid_stake, BOID_STAKE_CONTRACT_PATH)
        if args.build:
            eosioToken_c.build()
            boidStake_c.build()
        eosioToken_c.deploy()
        boidStake_c.deploy()


        ############# now we can call functions ##############
        ########## (aka actions) from the contract! ##########


        # Set up eos account as issuer of EOS
        # and boid account as issuer of BOID
        eosioToken_c.push_action(
Ejemplo n.º 5
0
    # 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)

    # build the token staking contract
    # if args.build:
    eosioToken_c.build()

    # deploy the token staking contract on the testnet
    eosioToken_c.deploy()

    # Set up master as issuer of EOS and boid as issuer of BOID
    # account.push_action(
    #		action_name,
    #		action_arguments_in_json,
    #		account_whose_permission_is_needed)
    eosioToken_c.push_action('create', {
        'issuer': eos,