From ded112794612b7060fd657e1aa453cbce1b5f87e Mon Sep 17 00:00:00 2001 From: Bryant Eisenbach Date: Sat, 1 Feb 2020 23:09:22 -0500 Subject: [PATCH] test: Added test from ganache-core --- tests/core/test_hdaccount.py | 32 +++++++++++++++++++++++++------- 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/tests/core/test_hdaccount.py b/tests/core/test_hdaccount.py index 2888963a..0324468f 100644 --- a/tests/core/test_hdaccount.py +++ b/tests/core/test_hdaccount.py @@ -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():