@@ -32,7 +32,7 @@ func runRoundAndGetOutcome(ctx context.Context, ocrTypeCodec ocrtypecodec.ExecCo
32
32
return outcome
33
33
}
34
34
35
- func Test_USDC_Transfer (t * testing.T ) {
35
+ func Test_LBTC_USDC_Transfer (t * testing.T ) {
36
36
ocrTypeCodec := ocrtypecodec .DefaultExecCodec
37
37
ctx := tests .Context (t )
38
38
@@ -43,6 +43,13 @@ func Test_USDC_Transfer(t *testing.T) {
43
43
usdcAddressBytes , err := cciptypes .NewUnknownAddressFromHex (usdcAddress )
44
44
require .NoError (t , err )
45
45
46
+ lbtcAddress := "0xc791ec14ad1d566425f006eec12a300343164ab1"
47
+ lbtcAddressBytes , err := cciptypes .NewUnknownAddressFromHex (lbtcAddress )
48
+ require .NoError (t , err )
49
+ lbtcMessageHash1 := internal .MustDecode ("0xa9165956caf08b3da46db4cccdd58098b2c3a90e57372f3f28d7d46672e2091b" )
50
+ lbtcMessageHash2 := internal .MustDecode ("0xc317b01e5a87000f8c51517227ea9ff07c9f4da646e8209c56424dc85ff50fe7" )
51
+ lbtcMessageHash3 := internal .MustDecode ("0x5f9b38941ce144fad0b6890a3e15bc67c7b51bb89751ab6f672f088f44e36b91" )
52
+
46
53
messages := []inmem.MessagesWithMetadata {
47
54
makeMsgWithMetadata (102 , sourceChain , destChain , false ),
48
55
makeMsgWithMetadata (103 , sourceChain , destChain , false ),
@@ -54,10 +61,21 @@ func Test_USDC_Transfer(t *testing.T) {
54
61
SourcePoolAddress : usdcAddressBytes ,
55
62
ExtraData : readerpkg .NewSourceTokenDataPayload (2 , 0 ).ToBytes (),
56
63
})),
57
- makeMsgWithMetadata (106 , sourceChain , destChain , false ,
64
+ makeMsgWithMetadata (106 , sourceChain , destChain , false , withTokens (cciptypes.RampTokenAmount {
65
+ SourcePoolAddress : lbtcAddressBytes ,
66
+ ExtraData : lbtcMessageHash1 ,
67
+ })),
68
+ makeMsgWithMetadata (107 , sourceChain , destChain , false , withTokens (cciptypes.RampTokenAmount {
69
+ SourcePoolAddress : lbtcAddressBytes ,
70
+ ExtraData : lbtcMessageHash2 ,
71
+ })),
72
+ makeMsgWithMetadata (108 , sourceChain , destChain , false ,
58
73
withTokens (cciptypes.RampTokenAmount {
59
74
SourcePoolAddress : usdcAddressBytes ,
60
75
ExtraData : readerpkg .NewSourceTokenDataPayload (3 , 0 ).ToBytes (),
76
+ }, cciptypes.RampTokenAmount {
77
+ SourcePoolAddress : lbtcAddressBytes ,
78
+ ExtraData : lbtcMessageHash3 ,
61
79
}),
62
80
),
63
81
}
@@ -68,7 +86,7 @@ func Test_USDC_Transfer(t *testing.T) {
68
86
newMessageSentEvent (0 , 6 , 3 , []byte {3 }),
69
87
}
70
88
71
- usdcAttestation104_106 := map [string ]string {
89
+ usdcAttestation104_108 := map [string ]string {
72
90
"0x0f43587da5355551d234a2ba24dde8edfe0e385346465d6d53653b6aa642992e" : `{
73
91
"status": "complete",
74
92
"attestation": "0x100001"
@@ -79,9 +97,23 @@ func Test_USDC_Transfer(t *testing.T) {
79
97
}` ,
80
98
}
81
99
100
+ lbtcAttestation106_108 := map [string ]string {
101
+ lbtcMessageHash1 .String (): `{
102
+ "message_hash": "0xa9165956caf08b3da46db4cccdd58098b2c3a90e57372f3f28d7d46672e2091b",
103
+ "status": "NOTARIZATION_STATUS_SESSION_APPROVED",
104
+ "attestation": "0x200001"
105
+ }` ,
106
+ lbtcMessageHash3 .String (): `{
107
+ "message_hash": "0x5f9b38941ce144fad0b6890a3e15bc67c7b51bb89751ab6f672f088f44e36b91",
108
+ "status": "NOTARIZATION_STATUS_SESSION_APPROVED",
109
+ "attestation": "0x200003"
110
+ }` ,
111
+ }
112
+
82
113
intTest := SetupSimpleTest (t , logger2 .Test (t ), []cciptypes.ChainSelector {sourceChain }, destChain )
83
114
intTest .WithMessages (messages , 1000 , time .Now ().Add (- 4 * time .Hour ), 1 , sourceChain )
84
- intTest .WithUSDC (usdcAddress , usdcAttestation104_106 , events , sourceChain )
115
+ intTest .WithUSDC (usdcAddress , usdcAttestation104_108 , events , sourceChain )
116
+ intTest .WithLBTC (lbtcAddress , lbtcAttestation106_108 , sourceChain )
85
117
runner := intTest .Start ()
86
118
defer intTest .Close ()
87
119
@@ -100,15 +132,19 @@ func Test_USDC_Transfer(t *testing.T) {
100
132
require .Len (t , outcome .CommitReports , 1 )
101
133
102
134
// Round 3 - Filter
103
- // Messages 102-104,106 are executed, 105 doesn 't have token data ready
135
+ // Messages 102-104,106,108 are executed, 105 and 107 don 't have token data ready
104
136
outcome = runRoundAndGetOutcome (ctx , ocrTypeCodec , t , runner )
105
137
require .NoError (t , err )
106
138
require .Len (t , outcome .Report .ChainReports , 1 )
107
139
sequenceNumbers := extractSequenceNumbers (outcome .Report .ChainReports [0 ].Messages )
108
- assert .ElementsMatch (t , sequenceNumbers , []cciptypes.SeqNum {102 , 103 , 104 , 106 })
140
+ assert .ElementsMatch (t , sequenceNumbers , []cciptypes.SeqNum {102 , 103 , 104 , 106 , 108 })
109
141
//Attestation data added to the USDC
110
142
assert .Equal (t , internal .MustDecodeRaw ("0x100001" ), outcome .Report .ChainReports [0 ].OffchainTokenData [2 ][0 ])
111
- assert .Equal (t , internal .MustDecodeRaw ("0x100003" ), outcome .Report .ChainReports [0 ].OffchainTokenData [3 ][0 ])
143
+ //Attestation data added to the LBTC
144
+ assert .Equal (t , internal .MustDecodeRaw ("0x200001" ), outcome .Report .ChainReports [0 ].OffchainTokenData [3 ][0 ])
145
+ //Attestation data added to the USDC+LBTC
146
+ assert .Equal (t , internal .MustDecodeRaw ("0x100003" ), outcome .Report .ChainReports [0 ].OffchainTokenData [4 ][0 ])
147
+ assert .Equal (t , internal .MustDecodeRaw ("0x200003" ), outcome .Report .ChainReports [0 ].OffchainTokenData [4 ][1 ])
112
148
113
149
intTest .usdcServer .AddResponse (
114
150
"0x70ef528624085241badbff913575c0ab50241e7cb6db183a5614922ab0bcba5d" ,
@@ -117,6 +153,14 @@ func Test_USDC_Transfer(t *testing.T) {
117
153
"attestation": "0x100002"
118
154
}` )
119
155
156
+ intTest .lbtcServer .AddResponse (
157
+ lbtcMessageHash2 .String (),
158
+ `{
159
+ "message_hash": "0xc317b01e5a87000f8c51517227ea9ff07c9f4da646e8209c56424dc85ff50fe7",
160
+ "status": "NOTARIZATION_STATUS_SESSION_APPROVED",
161
+ "attestation": "0x200002"
162
+ }` )
163
+
120
164
// Run 3 more rounds to get all attestations
121
165
for i := 0 ; i < 3 ; i ++ {
122
166
outcome = runRoundAndGetOutcome (ctx , ocrTypeCodec , t , runner )
@@ -125,7 +169,9 @@ func Test_USDC_Transfer(t *testing.T) {
125
169
require .Len (t , outcome .Report .ChainReports , 1 )
126
170
sequenceNumbers = extractSequenceNumbers (outcome .Report .ChainReports [0 ].Messages )
127
171
// 102, 103 and 104 are in the inflight message cache.
128
- assert .ElementsMatch (t , sequenceNumbers , []cciptypes.SeqNum {105 })
172
+ assert .ElementsMatch (t , sequenceNumbers , []cciptypes.SeqNum {105 , 107 })
129
173
//Attestation data added to the remaining USDC messages
130
174
assert .Equal (t , internal .MustDecodeRaw ("0x100002" ), outcome .Report .ChainReports [0 ].OffchainTokenData [0 ][0 ])
175
+ //Attestation data added to the remaining LBTC messages
176
+ assert .Equal (t , internal .MustDecodeRaw ("0x200002" ), outcome .Report .ChainReports [0 ].OffchainTokenData [1 ][0 ])
131
177
}
0 commit comments