Skip to content

Commit

Permalink
test: Added test from ganache-core
Browse files Browse the repository at this point in the history
  • Loading branch information
fubuloubu committed Feb 3, 2020
1 parent 337a53f commit ded1127
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions tests/core/test_hdaccount.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,33 @@
import pytest

from eth_account import (
Account,
)


# https://github.com/MetaMask/eth-hd-keyring/blob/master/test/index.js
def test_account_derivation():
words = "finish oppose decorate face calm tragic certain desk hour urge dinosaur mango"
a1 = Account.from_mnemonic(words)
a2 = Account.from_mnemonic(words, account_index=1)
assert a1.address == "0x1c96099350f13D558464eC79B9bE4445AA0eF579"
assert a2.address == "0x1b00AeD43a693F3a957F9FeB5cC08AFA031E37a0"
@pytest.mark.parametrize("mnemonic,expected_addresses", [
(
# Metamask
# https://github.com/MetaMask/eth-hd-keyring/blob/master/test/index.js
"finish oppose decorate face calm tragic certain desk hour urge dinosaur mango",
[
"0x1c96099350f13D558464eC79B9bE4445AA0eF579",
"0x1b00AeD43a693F3a957F9FeB5cC08AFA031E37a0",
],
),
(
# Ganache
# https://github.com/trufflesuite/ganache-core/blob/master/test/accounts.js
"into trim cross then helmet popular suit hammer cart shrug oval student",
[
"0x604a95C9165Bc95aE016a5299dd7d400dDDBEa9A",
],
),
])
def test_account_derivation(mnemonic, expected_addresses):
for idx, addr in enumerate(expected_addresses):
a = Account.from_mnemonic(mnemonic, account_index=idx)
assert a.address == addr


def test_account_restore():
Expand Down

0 comments on commit ded1127

Please sign in to comment.