Skip to content

Commit

Permalink
Fixing the e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kpachhai committed Oct 31, 2024
1 parent 984b6f0 commit 374630b
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
3 changes: 2 additions & 1 deletion scripts/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ ACK_GINKGO_RC=true ginkgo build ./tests/e2e || echo "ginkgo build failed"
additional_args=("$@")

if [[ ${MODE} == "run" ]]; then
echo "applying --ginkgo.focus=Ping and --reuse-network to setup local network"
echo "Applying --ginkgo.focus=Ping and --reuse-network to setup local network"
additional_args+=("--ginkgo.focus=Ping")
additional_args+=("--reuse-network")
fi
Expand All @@ -102,4 +102,5 @@ echo "running e2e tests"
--emission-address="$EMISSION_ADDRESS" \
--avalanchego-path="${AVALANCHEGO_PATH}" \
--plugin-dir="${AVALANCHEGO_PLUGIN_DIR}" \
--mode="${MODE}" \
"${additional_args[@]}"
4 changes: 3 additions & 1 deletion tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
const owner = "nuklaivm-e2e-tests"

var (
mode string
initialOwnerAddress string
emissionAddress string
flagVars *e2e.FlagVars
Expand Down Expand Up @@ -63,6 +64,7 @@ func init() {
flagVars = e2e.RegisterFlags()

// Register new flags for custom strings
flag.StringVar(&mode, "mode", "test", "Execution mode: 'run' or 'test'")
flag.StringVar(&initialOwnerAddress, "initial-owner-address", "", "Initial Owner Address")
flag.StringVar(&emissionAddress, "emission-address", "", "Emission Address")
}
Expand All @@ -71,7 +73,7 @@ func init() {
var _ = ginkgo.SynchronizedBeforeSuite(func() []byte {
require := require.New(ginkgo.GinkgoT())

gen, workloadFactory, err := workload.New(250, initialOwnerAddress, emissionAddress)
gen, workloadFactory, err := workload.New(250, initialOwnerAddress, emissionAddress, mode == "test")
require.NoError(err)

genesisBytes, err := json.Marshal(gen)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestIntegration(t *testing.T) {

var _ = ginkgo.BeforeSuite(func() {
require := require.New(ginkgo.GinkgoT())
genesis, workloadFactory, err := nuklaivmWorkload.New(0, "00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9", "00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9")
genesis, workloadFactory, err := nuklaivmWorkload.New(0, "00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9", "00c4cb545f748a28770042f893784ce85b107389004d6a0e0d6d7518eeae1292d9", true)
require.NoError(err)

genesisBytes, err := json.Marshal(genesis)
Expand Down
32 changes: 23 additions & 9 deletions tests/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,32 @@ type workloadFactory struct {
addrs []codec.Address
}

func New(minBlockGap int64, initialAddress, emissionAddress string) (*ngenesis.Genesis, workload.TxWorkloadFactory, error) {
var initialOwnerAddress codec.Address
if initialAddress == "" {
initialOwnerAddress = ed25519Addrs[0]
func New(minBlockGap int64, initialAddress, emissionAddress string, testMode bool) (*ngenesis.Genesis, workload.TxWorkloadFactory, error) {
var customAllocs []*genesis.CustomAllocation

if testMode {
// Prefund all addresses for "test" mode
customAllocs = make([]*genesis.CustomAllocation, 0, len(ed25519Addrs))
for _, addr := range ed25519Addrs {
customAllocs = append(customAllocs, &genesis.CustomAllocation{
Address: addr,
Balance: initialOwnerBalance,
})
}
} else {
address, err := codec.StringToAddress(initialAddress)
if err != nil {
return nil, nil, err
// Prefund only the initial address for "run" mode
var initialOwnerAddress codec.Address
if initialAddress == "" {
initialOwnerAddress = ed25519Addrs[0]
} else {
address, err := codec.StringToAddress(initialAddress)
if err != nil {
return nil, nil, err
}
initialOwnerAddress = address
}
initialOwnerAddress = address
customAllocs = []*genesis.CustomAllocation{{Address: initialOwnerAddress, Balance: initialOwnerBalance}}
}
customAllocs := []*genesis.CustomAllocation{{Address: initialOwnerAddress, Balance: initialOwnerBalance}}

emissionBalancerAddress := ed25519Addrs[0].String()
if emissionAddress != "" {
Expand Down

0 comments on commit 374630b

Please sign in to comment.