66 "encoding/hex"
77 "fmt"
88 "maps"
9- "math"
109 "math/big"
1110 "sort"
1211 "testing"
@@ -9571,10 +9570,6 @@ func TestCCIPRouter(t *testing.T) {
95719570 ix = sendChunk (t , 0 , chunkSize , 4 , data , bufferID , bufferPDA , transmitter )
95729571 result = testutils .SendAndConfirm (ctx , t , solanaGoClient , []solana.Instruction {ix }, transmitter , config .DefaultCommitment )
95739572 totalSolSpentInFees += result .Meta .Fee
9574- // Checking again after the terminator shuffling
9575- ix = sendChunk (t , 3 , terminatorSize , 4 , data , bufferID , bufferPDA , transmitter )
9576- result = testutils .SendAndFailWith (ctx , t , solanaGoClient , []solana.Instruction {ix }, transmitter , config .DefaultCommitment , []string {"Error Code: ExecutionReportBufferAlreadyContainsChunk" })
9577- totalSolSpentInFees += result .Meta .Fee
95789573 ix = sendChunk (t , 1 , terminatorSize , 4 , data , bufferID , bufferPDA , transmitter )
95799574 result = testutils .SendAndFailWith (ctx , t , solanaGoClient , []solana.Instruction {ix }, transmitter , config .DefaultCommitment , []string {"Error Code: ExecutionReportBufferInvalidChunkSize" })
95809575 totalSolSpentInFees += result .Meta .Fee
@@ -9592,19 +9587,12 @@ func TestCCIPRouter(t *testing.T) {
95929587 rent := (initialLamports - finalLamportsBeforeClose ) - totalSolSpentInFees
95939588
95949589 // We now close the buffer to recover the rent
9595- closeIx , err := ccip_offramp .NewCloseExecutionReportBufferInstruction (bufferID [:], bufferPDA , transmitter .PublicKey (), solana .SystemProgramID ).ValidateAndBuild ()
9590+ closeIx , err := ccip_offramp .NewCloseExecutionReportBufferInstruction (bufferID [:], bufferPDA , config . OfframpConfigPDA , transmitter .PublicKey (), solana .SystemProgramID ).ValidateAndBuild ()
95969591 require .NoError (t , err )
95979592 result = testutils .SendAndConfirm (ctx , t , solanaGoClient , []solana.Instruction {closeIx }, transmitter , config .DefaultCommitment )
95989593 finalLamportsAfterClose := getLamports (transmitter .PublicKey ())
95999594 closeDiff := finalLamportsAfterClose - finalLamportsBeforeClose
9600-
9601- within10PercentOf := func (a int , b int ) bool {
9602- diff := math .Abs (float64 (a - b ))
9603- return diff <= 0.1 * math .Max (float64 (a ), float64 (b ))
9604- }
9605-
9606- // TODO work out exact math: the rent is being recovered but there's some slight drift in the fees.
9607- require .True (t , within10PercentOf (int (rent ), int (closeDiff - result .Meta .Fee )))
9595+ require .Equal (t , rent - result .Meta .Fee , closeDiff )
96089596 })
96099597
96109598 t .Run ("When executing a report with oversized data, it fails, but it succeeds when buffered" , func (t * testing.T ) {
@@ -9794,7 +9782,7 @@ func TestCCIPRouter(t *testing.T) {
97949782 require .Equal (t , commitReport .MerkleRoot .MaxSeqNr , rootAccount .MaxMsgNr )
97959783 })
97969784
9797- t .Run ("Direct buffering execution, happy path" , func (t * testing.T ) {
9785+ t .Run ("Buffered execution, happy path" , func (t * testing.T ) {
97989786 transmitter := getTransmitter ()
97999787
98009788 msgAccounts := []solana.PublicKey {config .CcipLogicReceiver , config .ReceiverExternalExecutionConfigPDA , config .ReceiverTargetAccountPDA , solana .SystemProgramID }
0 commit comments