示例#1
0
    def test_local_testnet(self):
        setup.use_keosd(False)
        eosf.reset(is_verbose=0)
        eosf.stop(is_verbose=0)
        eosf.run(is_verbose=0)

        account_master = eosf.AccountMaster()
        print(account_master.info())
示例#2
0
 def test_reopen_with_stored_password(self): 
     setup.use_keosd(False)
     eosf.reset(is_verbose=0)
     eosf.Wallet()
     eosf.stop(is_verbose=0)
     node.run(is_verbose=0)
     
     wallet = eosf.Wallet()
     self.assertTrue(wallet.error)
示例#3
0
 def test_invalid_password(self): 
     setup.use_keosd(False)
     eosf.reset(is_verbose=0)
     wallet = eosf.Wallet()
     eosf.stop(is_verbose=0)
     eosf.run(is_verbose=0)        
     
     wallet = eosf.Wallet(
         "default", "EOS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV")
     self.assertTrue(wallet.error)
示例#4
0
def test():

    cprint("""
Start a local test EOSIO node, use `eosf.reset()`:
    """, 'magenta')

    reset = eosf.reset()

    cprint("""
Create a local wallet, use `wallet = eosf.Wallet()`:
    """, 'magenta')

    wallet = eosf.Wallet(is_verbose=2)

    account_master = eosf.AccountMaster()

    cprint("wallet.import_key(account_master):", 'magenta')
    wallet.import_key(account_master)

    account_bill = eosf.account()
    cprint("wallet.import_key(account_bill):", 'magenta')
    wallet.import_key(account_bill)

    cprint("wallet.import_key(alice):", 'magenta')
    account_alice = eosf.account()
    wallet.import_key(account_alice)

    return
示例#5
0
    def setUpClass(cls):
        global wallet 
        global account_master

        reset = eosf.reset()

        account_master = eosf.AccountMaster()
        wallet = eosf.Wallet()
        wallet.import_key(account_master)
示例#6
0
    def test_04(self):
        print("""
Start a local test EOSIO node:
        """)
        reset = eosf.reset()
        self.assertTrue(not reset.error)
        
        print("""
Create a local wallet (not with EOSIO `keosd` application):
        """)
        global wallet
        wallet = eosf.Wallet()
        self.assertTrue(not wallet.error)

        print("""
Implement the `eosio` master account as a `cleos.AccountMaster` object:
        """)
        global account_master
        account_master = eosf.AccountMaster()
        wallet.import_key(account_master)

        print("""
Create accounts `alice`, `bob` and `carol`:
        """)
        global alice
        alice = eosf.account()
        self.assertTrue(not alice.error)
        alice.account
        wallet.import_key(alice)

        global bob
        bob = eosf.account()
        self.assertTrue(not bob.error)
        wallet.import_key(bob)        

        global carol
        carol = eosf.account()
        self.assertTrue(not carol.error)
        wallet.import_key(carol)        
示例#7
0
 def test_05(self):
     node_reset = eosf.reset()
     self.assertTrue(node_reset)
示例#8
0
def test():
    global account_alice
    global account_carol
    global account_master
    global account_bill
    global account_test

    cprint(
        """
Start session: reset the local EOSIO node, create a wallet object, put the
master account into it.
    """, 'magenta')

    reset = eosf.reset()
    account_master = eosf.AccountMaster()
    wallet = eosf.Wallet()
    wallet.import_key(account_master)
    return
    cprint(
        """
Create an account object, named `account_alice`, with the `eosf.account()`, 
with default parameters: 

    -- using the `account_master` as the creator;
    -- using a random 12 character long name;
    -- using internally created `owner` and `active` keys.
    """, 'magenta')

    account_alice = eosf.account()
    wallet.import_key(account_alice)

    account_carol = eosf.account()
    wallet.import_key(account_carol)

    cprint(
        """
The following `account_bill` object represents the account of the name `bill`
    """, 'magenta')

    account_bill = eosf.account(name="bill")
    wallet.import_key(account_bill)

    account_test = eosf.account()
    wallet.import_key(account_test)

    cprint(
        """
The last account `account_test` is going to take a contract. Now, it does not have
any:
    """, 'magenta')

    account_test.code()

    cprint(
        """
Define a contract, with its code specified in the EOS repository 
(build/contracts/eosio.token), and deploy it:
    """, 'magenta')

    contract_test = eosf.Contract(account_test, "eosio.token")
    deploy = contract_test.deploy()
    account_test.code()

    time.sleep(1)

    action = account_test.push_action(
        "create", '{"issuer":"' + str(account_master) +
        '", "maximum_supply":"1000000000.0000 EOS", \
            "can_freeze":0, "can_recall":0, "can_whitelist":0}')

    action = contract_test.push_action(
        "issue",
        '{"to":"' + str(account_alice)
            + '", "quantity":"100.0000 EOS", "memo":"memo"}', \
            account_master)

    cprint(
        """
Experiments with the `eosio.token` contract are shown elsewere. 
Here, we show how the session accounts recover after restarting 
the session.
    """, 'magenta')

    account_alice = None
    account_bill = None
    account_carol = None
    account_test = None
    contract_test = None
    wallet = None

    wallet = eosf.Wallet()

    cprint(
        """
The old wallet is restored. It is possible, because there is a password map 
in the wallet directory. 

Note that this provision is available only if the `keosd` Wallet Manager is not 
used and wallets are managed by the local node - this condition is set with the
`setup.use_keosd(False)` statement above.
    """, 'magenta')

    wallet.restore_accounts(globals())
    print(account_alice.info())

    cprint("""
Continue operations on the restored account objects:
    """, 'magenta')

    action = account_test.push_action(
        "transfer", '{"from":"' + str(account_alice) + '", "to":"' +
        str(account_carol) + '", "quantity":"25.0000 EOS", "memo":"memo"}',
        account_alice)

    cprint(
        """
Note that the accounts have to be declared global, in order to be 
restorable with the current means.
    """, 'magenta')