-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(authority-claimer): add anvil dev accounts
- Loading branch information
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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, | ||
}) | ||
} | ||
} |