Skip to content

Commit 6061153

Browse files
committed
Update
1 parent 80090e5 commit 6061153

1 file changed

Lines changed: 67 additions & 51 deletions

File tree

examples/tests/examples_test.go

Lines changed: 67 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,8 @@ func TestCanton(t *testing.T) {
467467
t.Run("Send: Canton->EVM (Message Only)", func(t *testing.T) {
468468
messageReceiver := ccipReceiverContract
469469

470-
feeToken := amuletInstrumentID
471-
feeTokenTransferInstructionClient := amuletTransferInstructionClient
470+
feeToken := linkInstrumentId
471+
feeTokenTransferInstructionClient := transferInstructionEdsClient
472472

473473
// Get fee token input holdings
474474
feeTokenHoldings, err := testhelpers.ListHoldingsForInstrument(t.Context(), participant, feeToken)
@@ -477,6 +477,7 @@ func TestCanton(t *testing.T) {
477477
for i, holding := range feeTokenHoldings {
478478
feeTokenInputCids[i] = types.CONTRACT_ID(holding.ContractID)
479479
}
480+
feeTokenInputCids = []types.CONTRACT_ID{"00a923ff750bde2770df24811836a28e4106b1d4087e52ddd995f196d70e90283cca12122083dc750c95db42fe29438e9ee2a6ac5ed85a7d19938e2d99a1c0032e2776acab"}
480481

481482
transferFactory, err := testhelpers.GetTransferFactoryV2(t.Context(), feeTokenTransferInstructionClient, string(feeToken.Admin), splice_api_token_transfer_instruction_v1.Transfer{
482483
Sender: types.PARTY(participant.PartyID),
@@ -605,16 +606,20 @@ func TestCanton(t *testing.T) {
605606
messageReceiver := common.HexToAddress("0x90392A1E8A941098a3C75E0BDB172cFdE7E4f1f4")
606607
transferAmount := "0.123456789"
607608

608-
feeToken := amuletInstrumentID
609-
feeTokenTransferInstructionClient := amuletTransferInstructionClient
609+
feeToken := linkInstrumentId
610+
feeTokenTransferInstructionClient := transferInstructionEdsClient
610611

611612
// Manually set fee token input holding Cids
612613
// If empty, will automatically select all holdings
613-
feeTokenInputCids := []types.CONTRACT_ID{}
614+
feeTokenInputCids := []types.CONTRACT_ID{
615+
"00a923ff750bde2770df24811836a28e4106b1d4087e52ddd995f196d70e90283cca12122083dc750c95db42fe29438e9ee2a6ac5ed85a7d19938e2d99a1c0032e2776acab",
616+
}
614617

615618
// Manually set token transfer input holding Cids
616619
// If empty, will automatically select all holdings
617-
tokenTransferInputCids := []types.CONTRACT_ID{}
620+
tokenTransferInputCids := []types.CONTRACT_ID{
621+
"00e4b346645763de5dd202f20b1fa89e96b82b45b1ca3ce836587f9d3c6893e7a7ca12122099eb432b785c0a10610ac25cb1be32df24ba876bcea043057b12cae90c793481",
622+
}
618623

619624
// Get fee token input holdings, if not manually specified
620625
if len(feeTokenInputCids) == 0 {
@@ -871,57 +876,59 @@ func TestCanton(t *testing.T) {
871876
executorSendDisclosure, err := eds.GetExecutorSendDisclosure(t.Context(), executorEdsClient, msg, defaultExecutorAddress.InstanceAddress(), ccipSendDisclosure.CCVs)
872877
require.NoError(t, err)
873878

874-
sendArgs := sender.Send{
875-
DestinationChainSelector: types.NUMERIC(msg.DestinationChainSelector),
876-
Message: core.Canton2AnyMessage{
877-
Receiver: types.TEXT(msg.Receiver),
878-
Payload: types.TEXT(msg.Payload),
879-
TokenTransfer: &core.TokenTransfer{
880-
Token: *linkInstrumentId,
881-
Amount: types.NUMERIC(msg.TokenTransfer.Amount),
879+
getSendArgs := func() sender.Send {
880+
return sender.Send{
881+
DestinationChainSelector: types.NUMERIC(msg.DestinationChainSelector),
882+
Message: core.Canton2AnyMessage{
883+
Receiver: types.TEXT(msg.Receiver),
884+
Payload: types.TEXT(msg.Payload),
885+
TokenTransfer: &core.TokenTransfer{
886+
Token: *linkInstrumentId,
887+
Amount: types.NUMERIC(msg.TokenTransfer.Amount),
888+
},
889+
FeeToken: *feeToken,
890+
ExtraArgs: core.ExtraArgs{
891+
V3: &core.GenericExtraArgsV3{
892+
GasLimit: types.INT64(msg.GasLimit),
893+
Ccvs: nil,
894+
Executor: core.ExecutorExtraArg{
895+
ExecutorUseDefault: &core.ExecutorUseDefault{ExecutorArgs: ""},
896+
},
897+
TokenReceiver: "",
898+
TokenArgs: "",
899+
},
900+
},
882901
},
883-
FeeToken: *feeToken,
884-
ExtraArgs: core.ExtraArgs{
885-
V3: &core.GenericExtraArgsV3{
886-
GasLimit: types.INT64(msg.GasLimit),
887-
Ccvs: nil,
888-
Executor: core.ExecutorExtraArg{
889-
ExecutorUseDefault: &core.ExecutorUseDefault{ExecutorArgs: ""},
902+
Context: ccipSendDisclosure.ChoiceContext,
903+
RouterCid: types.CONTRACT_ID(routerCid),
904+
FeeTokenInput: sender.FeeTokenInput{
905+
SenderInputCids: feeTokenInputCids,
906+
FeeTokenConfigCid: types.CONTRACT_ID(ccipSendDisclosure.FeeTokenConfigCid),
907+
FeeTokenTransferFactory: types.CONTRACT_ID(transferFactory.FactoryID),
908+
FeeTokenExtraArgs: splice_api_token_metadata_v1.ExtraArgs{
909+
Context: choiceContext,
910+
Meta: splice_api_token_metadata_v1.Metadata{
911+
Values: map[string]types.TEXT{},
890912
},
891-
TokenReceiver: "",
892-
TokenArgs: "",
893913
},
894914
},
895-
},
896-
Context: ccipSendDisclosure.ChoiceContext,
897-
RouterCid: types.CONTRACT_ID(routerCid),
898-
FeeTokenInput: sender.FeeTokenInput{
899-
SenderInputCids: feeTokenInputCids,
900-
FeeTokenConfigCid: types.CONTRACT_ID(ccipSendDisclosure.FeeTokenConfigCid),
901-
FeeTokenTransferFactory: types.CONTRACT_ID(transferFactory.FactoryID),
902-
FeeTokenExtraArgs: splice_api_token_metadata_v1.ExtraArgs{
903-
Context: choiceContext,
904-
Meta: splice_api_token_metadata_v1.Metadata{
905-
Values: map[string]types.TEXT{},
915+
CcvSendInputs: []sender.CCVSendInput{
916+
{
917+
CcvAddress: ccvSendDisclosure.Address.Binding(),
918+
CcvCid: types.CONTRACT_ID(ccvSendDisclosure.ContractId),
919+
CcvExtraContext: splice_api_token_metadata_v1.ChoiceContext{},
906920
},
907921
},
908-
},
909-
CcvSendInputs: []sender.CCVSendInput{
910-
{
911-
CcvAddress: ccvSendDisclosure.Address.Binding(),
912-
CcvCid: types.CONTRACT_ID(ccvSendDisclosure.ContractId),
913-
CcvExtraContext: splice_api_token_metadata_v1.ChoiceContext{},
922+
TokenTransferInput: &sender.TokenTransferInput{
923+
SenderInputCids: tokenTransferInputCids,
924+
TokenPoolCid: types.CONTRACT_ID(tokenPoolSendDisclosure.ContractId),
925+
PoolExtraContext: tokenPoolSendDisclosure.ChoiceContext,
914926
},
915-
},
916-
TokenTransferInput: &sender.TokenTransferInput{
917-
SenderInputCids: tokenTransferInputCids,
918-
TokenPoolCid: types.CONTRACT_ID(tokenPoolSendDisclosure.ContractId),
919-
PoolExtraContext: tokenPoolSendDisclosure.ChoiceContext,
920-
},
921-
ExecutorInput: &sender.ExecutorInput{
922-
ExecutorCid: types.CONTRACT_ID(executorSendDisclosure.ContractId),
923-
ExecutorExtraContext: splice_api_token_metadata_v1.ChoiceContext{},
924-
},
927+
ExecutorInput: &sender.ExecutorInput{
928+
ExecutorCid: types.CONTRACT_ID(executorSendDisclosure.ContractId),
929+
ExecutorExtraContext: splice_api_token_metadata_v1.ChoiceContext{},
930+
},
931+
}
925932
}
926933
allDisclosures := slices.Concat(
927934
transferFactory.DisclosedContracts,
@@ -933,6 +940,7 @@ func TestCanton(t *testing.T) {
933940

934941
t.Run("Exceed max data size", func(t *testing.T) {
935942
// Exceed the max of 32kb
943+
sendArgs := getSendArgs()
936944
sendArgs.Message.Payload = types.TEXT(hex.EncodeToString(bytes.Repeat([]byte("A"), 32_001)))
937945

938946
_, err := participant.LedgerServices.Command.SubmitAndWaitForTransaction(t.Context(), &apiv2.SubmitAndWaitForTransactionRequest{
@@ -956,6 +964,7 @@ func TestCanton(t *testing.T) {
956964

957965
t.Run("Exceed gas limit", func(t *testing.T) {
958966
// Exceed the max of 15M
967+
sendArgs := getSendArgs()
959968
sendArgs.Message.ExtraArgs.V3.GasLimit = 15_000_001
960969

961970
_, err := participant.LedgerServices.Command.SubmitAndWaitForTransaction(t.Context(), &apiv2.SubmitAndWaitForTransactionRequest{
@@ -978,6 +987,7 @@ func TestCanton(t *testing.T) {
978987
})
979988

980989
t.Run("Invalid extraArgs", func(t *testing.T) {
990+
sendArgs := getSendArgs()
981991
sendArgs.Message.ExtraArgs.V3 = nil
982992

983993
_, err := participant.LedgerServices.Command.SubmitAndWaitForTransaction(t.Context(), &apiv2.SubmitAndWaitForTransactionRequest{
@@ -1000,6 +1010,7 @@ func TestCanton(t *testing.T) {
10001010
})
10011011

10021012
t.Run("Invalid dest chain selector", func(t *testing.T) {
1013+
sendArgs := getSendArgs()
10031014
sendArgs.DestinationChainSelector = types.NUMERIC("1234")
10041015

10051016
_, err := participant.LedgerServices.Command.SubmitAndWaitForTransaction(t.Context(), &apiv2.SubmitAndWaitForTransactionRequest{
@@ -1022,6 +1033,7 @@ func TestCanton(t *testing.T) {
10221033
})
10231034

10241035
t.Run("Invalid fee token", func(t *testing.T) {
1036+
sendArgs := getSendArgs()
10251037
sendArgs.Message.FeeToken = splice_api_token_holding_v1.InstrumentId{
10261038
Admin: ccipOwnerPartyID,
10271039
Id: "invalid-fee-token",
@@ -1047,6 +1059,7 @@ func TestCanton(t *testing.T) {
10471059
})
10481060

10491061
t.Run("No fee token holding", func(t *testing.T) {
1062+
sendArgs := getSendArgs()
10501063
sendArgs.FeeTokenInput.SenderInputCids = []types.CONTRACT_ID{}
10511064

10521065
_, err := participant.LedgerServices.Command.SubmitAndWaitForTransaction(t.Context(), &apiv2.SubmitAndWaitForTransactionRequest{
@@ -1069,6 +1082,7 @@ func TestCanton(t *testing.T) {
10691082
})
10701083

10711084
t.Run("Invalid token transfer instrument", func(t *testing.T) {
1085+
sendArgs := getSendArgs()
10721086
sendArgs.Message.TokenTransfer.Token = splice_api_token_holding_v1.InstrumentId{
10731087
Admin: ccipOwnerPartyID,
10741088
Id: "invalid-token-transfer",
@@ -1094,6 +1108,7 @@ func TestCanton(t *testing.T) {
10941108
})
10951109

10961110
t.Run("Zero transfer amount", func(t *testing.T) {
1111+
sendArgs := getSendArgs()
10971112
sendArgs.Message.TokenTransfer.Amount = "0.0"
10981113

10991114
_, err := participant.LedgerServices.Command.SubmitAndWaitForTransaction(t.Context(), &apiv2.SubmitAndWaitForTransactionRequest{
@@ -1116,6 +1131,7 @@ func TestCanton(t *testing.T) {
11161131
})
11171132

11181133
t.Run("Empty receiver", func(t *testing.T) {
1134+
sendArgs := getSendArgs()
11191135
sendArgs.Message.Receiver = ""
11201136

11211137
_, err := participant.LedgerServices.Command.SubmitAndWaitForTransaction(t.Context(), &apiv2.SubmitAndWaitForTransactionRequest{
@@ -1247,7 +1263,7 @@ func TestEVM(t *testing.T) {
12471263

12481264
receiverPartyHashed := contracts.HashedPartyFromString(receiverParty)
12491265

1250-
extraArgs, err := evm.NewV3ExtraArgs(finality, execGasLimit, executorAddress.Hex(), nil, nil, nil, nil)
1266+
extraArgs, err := evm.NewV3ExtraArgs(finality, execGasLimit, executorAddress.Hex(), nil, receiverPartyHashed.Bytes(), nil, nil)
12511267
require.NoError(t, err)
12521268

12531269
msg := routerwrapper.ClientEVM2AnyMessage{

0 commit comments

Comments
 (0)