Skip to content

Commit

Permalink
Fix flakey test
Browse files Browse the repository at this point in the history
  • Loading branch information
asoliman92 committed Jul 11, 2024
1 parent 1bab4fa commit b96ee58
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package ccip_integration_tests

import (
"bytes"
"testing"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -39,11 +38,23 @@ func TestPingPong(t *testing.T) {
log := logIter.Event
require.Equal(t, log.DestChainSelector, otherChain)
require.Equal(t, log.Message.Sender, pingPong.Address())
require.Equal(t, bytes.TrimLeft(log.Message.Receiver, "\x00"), pingPongs[otherChain][chainID].Address().Bytes())
chainPingPongAddr := pingPongs[otherChain][chainID].Address().Bytes()
// With chain agnostic addresses we need to pad the address to the correct length if the receiver is zero prefixed
paddedAddr := LeftPadByteArray(chainPingPongAddr, len(log.Message.Receiver))
require.Equal(t, log.Message.Receiver, paddedAddr)
}
}
}

func LeftPadByteArray(arr []byte, length int) []byte {
if len(arr) >= length {
return arr
}
padded := make([]byte, length)
copy(padded[length-len(arr):], arr)
return padded
}

// InitializeContracts initializes ping pong contracts on all chains and
// connects them all to each other.
func initializePingPongContracts(
Expand Down

0 comments on commit b96ee58

Please sign in to comment.