From 3e7329935402af089c990d359854b8ae48a6c66a Mon Sep 17 00:00:00 2001 From: Marcelo Politzer <251334+mpolitzer@users.noreply.github.com> Date: Tue, 8 Oct 2024 14:49:39 -0300 Subject: [PATCH] test(authority-claimer): add anvil dev accounts --- internal/anvil/account.go | 47 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 internal/anvil/account.go diff --git a/internal/anvil/account.go b/internal/anvil/account.go new file mode 100644 index 000000000..3bd213d14 --- /dev/null +++ b/internal/anvil/account.go @@ -0,0 +1,47 @@ +/* Anvil provides 10 dev accounts by default. Make them easy to use in tests */ +package anvil + +import ( + "crypto/ecdsa" + "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/common" +) + +/* Bundled PrivateKey, PublicKey and Address */ +type Account = struct{ + PrivateKey *ecdsa.PrivateKey; + PublicKey *ecdsa.PublicKey; + Address common.Address; +} + +/* Default anvil dev accounts */ +var DevAccounts = []Account{} + +func init() { + anvilPrivateKeys := []string{ + "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80", + "0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d", + "0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a", + "0x7c852118294e51e653712a81e05800f419141751be58f605c371e15141b007a6", + "0x47e179ec197488593b187f80a00eb0da91f1b9d0b13f8733639f19c30a34926a", + "0x8b3a350cf5c34c9194ca85829a2df0ec3153be0318b5e2d3348e872092edffba", + "0x92db14e403b83dfe3df233f83dfa3a0d7096f21ca9b0d6d6b8d88b2b4ec1564e", + "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356", + "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97", + "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6", + } + for _, key := range(anvilPrivateKeys) { + privateKey, err := crypto.HexToECDSA(key[2:]) + if err != nil { + panic(err) + } + publicKey := privateKey.Public().(*ecdsa.PublicKey) + address := crypto.PubkeyToAddress(*publicKey) + + DevAccounts = append(DevAccounts, Account{ + PrivateKey: privateKey, + PublicKey: publicKey, + Address: address, + }) + } +}