Skip to content

Commit

Permalink
more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
sasa-ethernal committed May 24, 2024
1 parent f4eb0b5 commit 259214d
Showing 1 changed file with 29 additions and 27 deletions.
56 changes: 29 additions & 27 deletions e2e-polybft/e2e/apex_bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,10 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
fmt.Printf("Funding %v Wallets\n", instances)

for i := 0; i < instances; i++ {
if (i+1)%100 == 0 {
fmt.Printf("Funded %v..%v\n", i-99, i)
}

walletKeys[i], err = wallet.NewStakeWalletManager().Create(path.Join(apex.PrimeCluster.Config.Dir("keys")), true)
require.NoError(t, err)

Expand Down Expand Up @@ -754,21 +758,18 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
user.PrimeAddress, receivers, cardanofw.GetDestinationChainID(true))
require.NoError(t, err)

txHash, err := cardanofw.SendTx(
_, err = cardanofw.SendTx(
ctx, txProviderPrime, walletKeys[idx], (sendAmount + feeAmount), apex.Bridge.PrimeMultisigAddr,
apex.PrimeCluster.Config.NetworkMagic, bridgingRequestMetadata)
require.NoError(t, err)

apiURL, err := apex.Bridge.GetBridgingAPI()
require.NoError(t, err)
cardanofw.WaitForInvalidState(t, ctx, apiURL, apiKey, txHash)
fmt.Printf("Tx %v invalid. hash: %s\n", idx+1, txHash)
}
}(i)
}

wg.Wait()

fmt.Printf("All tx sent, waiting for confirmation.\n")

expectedAmount := prevAmount.Uint64() + uint64(succeededCount)*sendAmount
err = wallet.WaitForAmount(context.Background(), txProviderVector, user.VectorAddress, func(val *big.Int) bool {
return val.Cmp(new(big.Int).SetUint64(expectedAmount)) == 0
Expand Down Expand Up @@ -799,6 +800,10 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
fmt.Printf("Funding %v Wallets\n", instances)

for i := 0; i < instances; i++ {
if (i+1)%100 == 0 {
fmt.Printf("Funded %v..%v\n", i-99, i)
}

walletKeys[i], err = wallet.NewStakeWalletManager().Create(path.Join(apex.PrimeCluster.Config.Dir("keys")), true)
require.NoError(t, err)

Expand Down Expand Up @@ -836,25 +841,22 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
user.PrimeAddress, receivers, cardanofw.GetDestinationChainID(true))
require.NoError(t, err)

txHash, err := cardanofw.SendTx(
_, err = cardanofw.SendTx(
ctx, txProviderPrime, walletKeys[idx], (sendAmount + feeAmount), apex.Bridge.PrimeMultisigAddr,
apex.PrimeCluster.Config.NetworkMagic, bridgingRequestMetadata)
require.NoError(t, err)

apiURL, err := apex.Bridge.GetBridgingAPI()
require.NoError(t, err)
cardanofw.WaitForInvalidState(t, ctx, apiURL, apiKey, txHash)
fmt.Printf("Tx %v invalid. hash: %s\n", idx+1, txHash)
}
}(i)
}

wg.Wait()

fmt.Printf("All tx sent, waiting for confirmation.\n")

expectedAmount := prevAmount.Uint64() + uint64(succeededCount)*sendAmount
err = wallet.WaitForAmount(context.Background(), txProviderVector, user.VectorAddress, func(val *big.Int) bool {
return val.Cmp(new(big.Int).SetUint64(expectedAmount)) == 0
}, 100, time.Second*10)
}, 1000, time.Second*10)
require.NoError(t, err)

fmt.Printf("%v TXs confirmed\n", succeededCount)
Expand Down Expand Up @@ -884,6 +886,10 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
fmt.Printf("Funding %v Wallets\n", instances)

for i := 0; i < instances; i++ {
if (i+1)%100 == 0 {
fmt.Printf("Funded %v..%v on prime\n", i-99, i)
}

walletKeysPrime[i], err = wallet.NewStakeWalletManager().Create(path.Join(apex.PrimeCluster.Config.Dir("keys")), true)
require.NoError(t, err)

Expand All @@ -894,6 +900,10 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
}

for i := 0; i < instances; i++ {
if (i+1)%100 == 0 {
fmt.Printf("Funded %v..%v on vector\n", i-99, i)
}

walletKeysVector[i], err = wallet.NewStakeWalletManager().Create(path.Join(apex.VectorCluster.Config.Dir("keys")), true)
require.NoError(t, err)

Expand Down Expand Up @@ -932,15 +942,10 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
user.PrimeAddress, receivers, cardanofw.GetDestinationChainID(true))
require.NoError(t, err)

txHash, err := cardanofw.SendTx(
_, err = cardanofw.SendTx(
ctx, txProviderPrime, walletKeysPrime[idx], (sendAmount + feeAmount), apex.Bridge.PrimeMultisigAddr,
apex.PrimeCluster.Config.NetworkMagic, bridgingRequestMetadata)
require.NoError(t, err)

apiURL, err := apex.Bridge.GetBridgingAPI()
require.NoError(t, err)
cardanofw.WaitForInvalidState(t, ctx, apiURL, apiKey, txHash)
fmt.Printf("Prime Tx %v invalid. hash: %s\n", idx+1, txHash)
}
}(i)

Expand All @@ -967,32 +972,29 @@ func TestE2E_ApexBridge_ValidScenarios(t *testing.T) {
user.VectorAddress, receivers, cardanofw.GetDestinationChainID(false))
require.NoError(t, err)

txHash, err := cardanofw.SendTx(
_, err = cardanofw.SendTx(
ctx, txProviderVector, walletKeysVector[idx], (sendAmount + feeAmount), apex.Bridge.VectorMultisigAddr,
apex.VectorCluster.Config.NetworkMagic, bridgingRequestMetadata)
require.NoError(t, err)

apiURL, err := apex.Bridge.GetBridgingAPI()
require.NoError(t, err)
cardanofw.WaitForInvalidState(t, ctx, apiURL, apiKey, txHash)
fmt.Printf("Tx %v invalid. hash: %s\n", idx+1, txHash)
}
}(i)
}

wg.Wait()

fmt.Printf("All tx sent, waiting for confirmation.\n")

expectedAmountPrime := prevAmountPrime.Uint64() + uint64(succeededCountPrime)*sendAmount
err = wallet.WaitForAmount(context.Background(), txProviderVector, user.VectorAddress, func(val *big.Int) bool {
return val.Cmp(new(big.Int).SetUint64(expectedAmountPrime)) == 0
}, 100, time.Second*10)
}, 1000, time.Second*10)
require.NoError(t, err)
fmt.Printf("%v TXs confirmed on Prime\n", succeededCountPrime)

expectedAmountVector := prevAmountVector.Uint64() + uint64(succeededCountVector)*sendAmount
err = wallet.WaitForAmount(context.Background(), txProviderPrime, user.PrimeAddress, func(val *big.Int) bool {
return val.Cmp(new(big.Int).SetUint64(expectedAmountVector)) == 0
}, 100, time.Second*10)
}, 1000, time.Second*10)
require.NoError(t, err)
fmt.Printf("%v TXs confirmed on Vector\n", succeededCountVector)

Expand Down

0 comments on commit 259214d

Please sign in to comment.