def test_create_new_account_with_text_password(tmpdir):
    data_dir = str(tmpdir.mkdir("data-dir"))

    assert not get_accounts(data_dir)

    account_0 = create_new_account(data_dir, b'some-text-password')
    account_1 = create_new_account(data_dir, b'some-text-password')

    accounts = get_accounts(data_dir)
    assert sorted((account_0, account_1)) == sorted(tuple(set(accounts)))
Exemplo n.º 2
0
def test_create_new_account_with_text_password(tmpdir):
    data_dir = str(tmpdir.mkdir("data-dir"))

    assert not get_accounts(data_dir)

    account_0 = create_new_account(data_dir, b'some-text-password')
    account_1 = create_new_account(data_dir, b'some-text-password')

    accounts = get_accounts(data_dir)
    assert (account_0, account_1) == accounts
def test_create_new_account_with_file_based_password(tmpdir):
    pw_file_path = str(tmpdir.mkdir("data-dir").join('geth_password_file'))

    with open(pw_file_path, 'w') as pw_file:
        pw_file.write("some-text-password-in-a-file")

    data_dir = os.path.dirname(pw_file_path)

    assert not get_accounts(data_dir)

    account_0 = create_new_account(data_dir, pw_file_path)
    account_1 = create_new_account(data_dir, pw_file_path)

    accounts = get_accounts(data_dir)
    assert sorted((account_0, account_1)) == sorted(tuple(set(accounts)))
Exemplo n.º 4
0
def test_create_new_account_with_file_based_password(tmpdir):
    pw_file_path = str(tmpdir.mkdir("data-dir").join('geth_password_file'))

    with open(pw_file_path, 'w') as pw_file:
        pw_file.write("some-text-password-in-a-file")

    data_dir = os.path.dirname(pw_file_path)

    assert not get_accounts(data_dir)

    account_0 = create_new_account(data_dir, pw_file_path)
    account_1 = create_new_account(data_dir, pw_file_path)

    accounts = get_accounts(data_dir)
    assert (account_0, account_1) == accounts
Exemplo n.º 5
0
def test_multiple_accounts(three_account_data_dir):
    data_dir = three_account_data_dir
    accounts = get_accounts(data_dir=data_dir)
    assert accounts == (
        b'0xae71658b3ab452f7e4f03bda6f777b860b2e2ff2',
        b'0xe8e085862a8d951dd78ec5ea784b3e22ee1ca9c6',
        b'0x0da70f43a568e88168436be52ed129f4a9bbdaf5',
    )
Exemplo n.º 6
0
def test_multiple_accounts(three_account_data_dir):
    data_dir = three_account_data_dir
    accounts = get_accounts(data_dir=data_dir)
    assert accounts == (
        b'0xae71658b3ab452f7e4f03bda6f777b860b2e2ff2',
        b'0xe8e085862a8d951dd78ec5ea784b3e22ee1ca9c6',
        b'0x0da70f43a568e88168436be52ed129f4a9bbdaf5',
    )
Exemplo n.º 7
0
 def ensure_account_exists(self, password: str) -> str:
     accounts = get_accounts(**self.geth_kwargs)
     if not accounts:
         account = create_new_account(password=password.encode(), **self.geth_kwargs)
     else:
         account = accounts[0]  # etherbase by default
     checksum_address = to_checksum_address(account.decode())
     return checksum_address
Exemplo n.º 8
0
def test_single_account(one_account_data_dir):
    data_dir = one_account_data_dir
    accounts = get_accounts(data_dir=data_dir)
    assert accounts == (b'0xae71658b3ab452f7e4f03bda6f777b860b2e2ff2', )
Exemplo n.º 9
0
def test_no_accounts(no_account_data_dir):
    data_dir = no_account_data_dir
    accounts = get_accounts(data_dir=data_dir)
    assert accounts == tuple()
Exemplo n.º 10
0
def test_single_account(one_account_data_dir):
    data_dir = one_account_data_dir
    accounts = get_accounts(data_dir=data_dir)
    assert accounts == (b'0xae71658b3ab452f7e4f03bda6f777b860b2e2ff2',)
Exemplo n.º 11
0
def test_no_accounts(no_account_data_dir):
    data_dir = no_account_data_dir
    accounts = get_accounts(data_dir=data_dir)
    assert accounts == tuple()
 def accounts(self):
     return get_accounts(**self.geth_kwargs)
Exemplo n.º 13
0
 def accounts(self):
     return get_accounts(**self.geth_kwargs)