Skip to content

Commit e3d0278

Browse files
authored
e2e: Rename 'funded key' to 'pre-funded key' for consistency (#2455)
1 parent f5266fb commit e3d0278

File tree

12 files changed

+55
-55
lines changed

12 files changed

+55
-55
lines changed

tests/e2e/c/dynamic_fees.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ var _ = e2e.DescribeCChain("[Dynamic Fees]", func() {
4242
privateNetwork := e2e.Env.NewPrivateNetwork()
4343

4444
ginkgo.By("allocating a pre-funded key")
45-
key := privateNetwork.GetConfig().FundedKeys[0]
45+
key := privateNetwork.GetConfig().PreFundedKeys[0]
4646
ethAddress := evm.GetEthAddress(key)
4747

4848
ginkgo.By("initializing a coreth client")

tests/e2e/c/interchain_workflow.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var _ = e2e.DescribeCChain("[Interchain Workflow]", func() {
3737
ethClient := e2e.NewEthClient(nodeURI)
3838

3939
ginkgo.By("allocating a pre-funded key to send from and a recipient key to deliver to")
40-
senderKey := e2e.Env.AllocateFundedKey()
40+
senderKey := e2e.Env.AllocatePreFundedKey()
4141
senderEthAddress := evm.GetEthAddress(senderKey)
4242
recipientKey, err := secp256k1.NewPrivateKey()
4343
require.NoError(err)

tests/e2e/p/staking_rewards.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ var _ = ginkgo.Describe("[Staking Rewards]", func() {
8787

8888
ginkgo.By("creating keychain and P-Chain wallet")
8989
keychain := secp256k1fx.NewKeychain(rewardKeys...)
90-
fundedKey := e2e.Env.AllocateFundedKey()
90+
fundedKey := e2e.Env.AllocatePreFundedKey()
9191
keychain.Add(fundedKey)
9292
nodeURI := e2e.Env.GetRandomNodeURI()
9393
baseWallet := e2e.NewWallet(keychain, nodeURI)

tests/e2e/x/transfer/virtuous.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ var _ = e2e.DescribeXChainSerial("[Virtuous Transfer Tx AVAX]", func() {
6969

7070
// Ensure the same set of 10 keys is used for all tests
7171
// by retrieving them outside of runFunc.
72-
testKeys := e2e.Env.AllocateFundedKeys(10)
72+
testKeys := e2e.Env.AllocatePreFundedKeys(10)
7373

7474
runFunc := func(round int) {
7575
tests.Outf("{{green}}\n\n\n\n\n\n---\n[ROUND #%02d]:{{/}}\n", round)

tests/fixture/e2e/env.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func NewTestEnvironment(flagVars *FlagVars) *TestEnvironment {
7575
tests.Outf("{{green}}network URIs: {{/}} %+v\n", uris)
7676

7777
testDataServerURI, err := fixture.ServeTestData(fixture.TestData{
78-
FundedKeys: network.FundedKeys,
78+
PreFundedKeys: network.PreFundedKeys,
7979
})
8080
tests.Outf("{{green}}test data server URI: {{/}} %+v\n", testDataServerURI)
8181
require.NoError(err)
@@ -104,21 +104,21 @@ func (te *TestEnvironment) GetNetwork() tmpnet.Network {
104104
}
105105

106106
// Retrieve the specified number of funded keys allocated for the caller's exclusive use.
107-
func (te *TestEnvironment) AllocateFundedKeys(count int) []*secp256k1.PrivateKey {
108-
keys, err := fixture.AllocateFundedKeys(te.TestDataServerURI, count)
107+
func (te *TestEnvironment) AllocatePreFundedKeys(count int) []*secp256k1.PrivateKey {
108+
keys, err := fixture.AllocatePreFundedKeys(te.TestDataServerURI, count)
109109
te.require.NoError(err)
110-
tests.Outf("{{blue}} allocated funded key(s): %+v{{/}}\n", keys)
110+
tests.Outf("{{blue}} allocated pre-funded key(s): %+v{{/}}\n", keys)
111111
return keys
112112
}
113113

114114
// Retrieve a funded key allocated for the caller's exclusive use.
115-
func (te *TestEnvironment) AllocateFundedKey() *secp256k1.PrivateKey {
116-
return te.AllocateFundedKeys(1)[0]
115+
func (te *TestEnvironment) AllocatePreFundedKey() *secp256k1.PrivateKey {
116+
return te.AllocatePreFundedKeys(1)[0]
117117
}
118118

119119
// Create a new keychain with the specified number of test keys.
120120
func (te *TestEnvironment) NewKeychain(count int) *secp256k1fx.Keychain {
121-
keys := te.AllocateFundedKeys(count)
121+
keys := te.AllocatePreFundedKeys(count)
122122
return secp256k1fx.NewKeychain(keys...)
123123
}
124124

tests/fixture/e2e/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func StartLocalNetwork(avalancheGoExecPath string, networkDir string) *local.Loc
235235
},
236236
},
237237
tmpnet.DefaultNodeCount,
238-
tmpnet.DefaultFundedKeyCount,
238+
tmpnet.DefaultPreFundedKeyCount,
239239
)
240240
require.NoError(err)
241241
ginkgo.DeferCleanup(func() {

tests/fixture/test_data_server.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ var (
3333
)
3434

3535
type TestData struct {
36-
FundedKeys []*secp256k1.PrivateKey
36+
PreFundedKeys []*secp256k1.PrivateKey
3737
}
3838

3939
// http server allocating resources to tests potentially executing in parallel
@@ -68,14 +68,14 @@ func (s *testDataServer) allocateKeys(w http.ResponseWriter, r *http.Request) {
6868
defer s.lock.Unlock()
6969

7070
// Only fulfill requests for available keys
71-
if keyCount > len(s.FundedKeys) {
71+
if keyCount > len(s.PreFundedKeys) {
7272
http.Error(w, requestedKeyCountExceedsAvailable, http.StatusInternalServerError)
7373
return
7474
}
7575

7676
// Allocate the requested number of keys
77-
remainingKeys := len(s.FundedKeys) - keyCount
78-
allocatedKeys := s.FundedKeys[remainingKeys:]
77+
remainingKeys := len(s.PreFundedKeys) - keyCount
78+
allocatedKeys := s.PreFundedKeys[remainingKeys:]
7979

8080
keysDoc := &keysDocument{
8181
Keys: allocatedKeys,
@@ -88,7 +88,7 @@ func (s *testDataServer) allocateKeys(w http.ResponseWriter, r *http.Request) {
8888

8989
// Forget the allocated keys
9090
utils.ZeroSlice(allocatedKeys)
91-
s.FundedKeys = s.FundedKeys[:remainingKeys]
91+
s.PreFundedKeys = s.PreFundedKeys[:remainingKeys]
9292
}
9393

9494
// Serve test data via http to ensure allocation is synchronized even when
@@ -122,9 +122,9 @@ func ServeTestData(testData TestData) (string, error) {
122122
return address, nil
123123
}
124124

125-
// Retrieve the specified number of funded test keys from the provided URI. A given
125+
// Retrieve the specified number of pre-funded test keys from the provided URI. A given
126126
// key is allocated at most once during the life of the test data server.
127-
func AllocateFundedKeys(baseURI string, count int) ([]*secp256k1.PrivateKey, error) {
127+
func AllocatePreFundedKeys(baseURI string, count int) ([]*secp256k1.PrivateKey, error) {
128128
if count <= 0 {
129129
return nil, errInvalidKeyCount
130130
}
@@ -144,13 +144,13 @@ func AllocateFundedKeys(baseURI string, count int) ([]*secp256k1.PrivateKey, err
144144

145145
resp, err := http.DefaultClient.Do(req)
146146
if err != nil {
147-
return nil, fmt.Errorf("failed to request funded keys: %w", err)
147+
return nil, fmt.Errorf("failed to request pre-funded keys: %w", err)
148148
}
149149
defer resp.Body.Close()
150150

151151
body, err := io.ReadAll(resp.Body)
152152
if err != nil {
153-
return nil, fmt.Errorf("failed to read response for funded keys: %w", err)
153+
return nil, fmt.Errorf("failed to read response for pre-funded keys: %w", err)
154154
}
155155
if resp.StatusCode != http.StatusOK {
156156
if strings.TrimSpace(string(body)) == requestedKeyCountExceedsAvailable {
@@ -161,7 +161,7 @@ func AllocateFundedKeys(baseURI string, count int) ([]*secp256k1.PrivateKey, err
161161

162162
keysDoc := &keysDocument{}
163163
if err := json.Unmarshal(body, keysDoc); err != nil {
164-
return nil, fmt.Errorf("failed to unmarshal funded keys: %w", err)
164+
return nil, fmt.Errorf("failed to unmarshal pre-funded keys: %w", err)
165165
}
166166
return keysDoc.Keys, nil
167167
}

tests/fixture/test_data_server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// Check that funded test keys can be served from an http server to
1616
// ensure at-most-once allocation when tests are executed in parallel.
17-
func TestAllocateFundedKeys(t *testing.T) {
17+
func TestAllocatePreFundedKeys(t *testing.T) {
1818
require := require.New(t)
1919

2020
keys := make([]*secp256k1.PrivateKey, 5)
@@ -25,7 +25,7 @@ func TestAllocateFundedKeys(t *testing.T) {
2525
}
2626

2727
uri, err := ServeTestData(TestData{
28-
FundedKeys: keys,
28+
PreFundedKeys: keys,
2929
})
3030
require.NoError(err)
3131

@@ -63,7 +63,7 @@ func TestAllocateFundedKeys(t *testing.T) {
6363
}
6464
for _, tc := range testCases {
6565
t.Run(tc.name, func(t *testing.T) {
66-
keys, err := AllocateFundedKeys(uri, tc.count)
66+
keys, err := AllocatePreFundedKeys(uri, tc.count)
6767
require.ErrorIs(err, tc.expectedError)
6868

6969
addresses := make([]ids.ShortID, len(keys))

tests/fixture/tmpnet/cmd/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ func main() {
4646
rootCmd.AddCommand(versionCmd)
4747

4848
var (
49-
rootDir string
50-
execPath string
51-
nodeCount uint8
52-
fundedKeyCount uint8
49+
rootDir string
50+
execPath string
51+
nodeCount uint8
52+
preFundedKeyCount uint8
5353
)
5454
startNetworkCmd := &cobra.Command{
5555
Use: "start-network",
@@ -68,7 +68,7 @@ func main() {
6868
}
6969
ctx, cancel := context.WithTimeout(context.Background(), local.DefaultNetworkStartTimeout)
7070
defer cancel()
71-
network, err := local.StartNetwork(ctx, os.Stdout, rootDir, network, int(nodeCount), int(fundedKeyCount))
71+
network, err := local.StartNetwork(ctx, os.Stdout, rootDir, network, int(nodeCount), int(preFundedKeyCount))
7272
if err != nil {
7373
return err
7474
}
@@ -95,7 +95,7 @@ func main() {
9595
startNetworkCmd.PersistentFlags().StringVar(&rootDir, "root-dir", os.Getenv(local.RootDirEnvName), "The path to the root directory for local networks")
9696
startNetworkCmd.PersistentFlags().StringVar(&execPath, "avalanchego-path", os.Getenv(local.AvalancheGoPathEnvName), "The path to an avalanchego binary")
9797
startNetworkCmd.PersistentFlags().Uint8Var(&nodeCount, "node-count", tmpnet.DefaultNodeCount, "Number of nodes the network should initially consist of")
98-
startNetworkCmd.PersistentFlags().Uint8Var(&fundedKeyCount, "funded-key-count", tmpnet.DefaultFundedKeyCount, "Number of funded keys the network should start with")
98+
startNetworkCmd.PersistentFlags().Uint8Var(&preFundedKeyCount, "pre-funded-key-count", tmpnet.DefaultPreFundedKeyCount, "Number of pre-funded keys the network should start with")
9999
rootCmd.AddCommand(startNetworkCmd)
100100

101101
var networkDir string

tests/fixture/tmpnet/config.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ import (
3333
)
3434

3535
const (
36-
DefaultNodeCount = 2 // Minimum required to ensure connectivity-based health checks will pass
37-
DefaultFundedKeyCount = 50
36+
DefaultNodeCount = 2 // Minimum required to ensure connectivity-based health checks will pass
37+
DefaultPreFundedKeyCount = 50
3838

3939
DefaultGasLimit = uint64(100_000_000) // Gas limit is arbitrary
4040

4141
// Arbitrarily large amount of AVAX to fund keys on the X-Chain for testing
42-
DefaultFundedKeyXChainAmount = 30 * units.MegaAvax
42+
DefaultPreFundedKeyXChainAmount = 30 * units.MegaAvax
4343

4444
// A short min stake duration enables testing of staking logic.
4545
DefaultMinStakeDuration = time.Second
4646
)
4747

4848
var (
4949
// Arbitrarily large amount of AVAX (10^12) to fund keys on the C-Chain for testing
50-
DefaultFundedKeyCChainAmount = new(big.Int).Exp(big.NewInt(10), big.NewInt(30), nil)
50+
DefaultPreFundedKeyCChainAmount = new(big.Int).Exp(big.NewInt(10), big.NewInt(30), nil)
5151

5252
errNoKeysForGenesis = errors.New("failed to generate genesis: no keys to fund")
5353
errInvalidNetworkIDForGenesis = errors.New("network ID can't be mainnet, testnet or local network ID")
@@ -121,10 +121,10 @@ func DefaultJSONMarshal(v interface{}) ([]byte, error) {
121121
// NetworkConfig defines configuration shared or
122122
// common to all nodes in a given network.
123123
type NetworkConfig struct {
124-
Genesis *genesis.UnparsedConfig
125-
CChainConfig FlagsMap
126-
DefaultFlags FlagsMap
127-
FundedKeys []*secp256k1.PrivateKey
124+
Genesis *genesis.UnparsedConfig
125+
CChainConfig FlagsMap
126+
DefaultFlags FlagsMap
127+
PreFundedKeys []*secp256k1.PrivateKey
128128
}
129129

130130
// Ensure genesis is generated if not already present.
@@ -133,17 +133,17 @@ func (c *NetworkConfig) EnsureGenesis(networkID uint32, initialStakers []genesis
133133
return nil
134134
}
135135

136-
if len(c.FundedKeys) == 0 {
136+
if len(c.PreFundedKeys) == 0 {
137137
return errNoKeysForGenesis
138138
}
139139

140140
// Ensure pre-funded keys have arbitrary large balances on both chains to support testing
141-
xChainBalances := make(XChainBalanceMap, len(c.FundedKeys))
142-
cChainBalances := make(core.GenesisAlloc, len(c.FundedKeys))
143-
for _, key := range c.FundedKeys {
144-
xChainBalances[key.Address()] = DefaultFundedKeyXChainAmount
141+
xChainBalances := make(XChainBalanceMap, len(c.PreFundedKeys))
142+
cChainBalances := make(core.GenesisAlloc, len(c.PreFundedKeys))
143+
for _, key := range c.PreFundedKeys {
144+
xChainBalances[key.Address()] = DefaultPreFundedKeyXChainAmount
145145
cChainBalances[evm.GetEthAddress(key)] = core.GenesisAccount{
146-
Balance: DefaultFundedKeyCChainAmount,
146+
Balance: DefaultPreFundedKeyCChainAmount,
147147
}
148148
}
149149

0 commit comments

Comments
 (0)