@@ -45,6 +45,15 @@ import {
4545  HERMES_ETH_UNIQUE_EXPO , 
4646  HERMES_ETH_UNIQUE_PRICE , 
4747  HERMES_ETH_UNIQUE_PUBLISH_TIME , 
48+   HERMES_SOL_TON_PYTH_USDT_UPDATE , 
49+   PYTH_PRICE_FEED_ID , 
50+   SOL_PRICE_FEED_ID , 
51+   TON_PRICE_FEED_ID , 
52+   USDT_PRICE_FEED_ID , 
53+   HERMES_SOL_UNIQUE_PUBLISH_TIME , 
54+   HERMES_SOL_UNIQUE_PRICE , 
55+   HERMES_SOL_UNIQUE_CONF , 
56+   HERMES_SOL_UNIQUE_EXPO , 
4857}  from  "./utils/pyth" ; 
4958import  {  GUARDIAN_SET_0 ,  MAINNET_UPGRADE_VAAS  }  from  "./utils/wormhole" ; 
5059import  {  DataSource  }  from  "@pythnetwork/xc-admin-common" ; 
@@ -1110,6 +1119,86 @@ describe("PythTest", () => {
11101119    ) ; 
11111120  } ) ; 
11121121
1122+   it ( "should successfully parse price feed updates with more than 3 price feed ids" ,  async  ( )  =>  { 
1123+     await  deployContract ( ) ; 
1124+     await  updateGuardianSets ( pythTest ,  deployer ) ; 
1125+ 
1126+     const  sentValue  =  toNano ( "1" ) ; 
1127+     const  result  =  await  pythTest . sendParsePriceFeedUpdates ( 
1128+       deployer . getSender ( ) , 
1129+       Buffer . from ( HERMES_SOL_TON_PYTH_USDT_UPDATE ,  "hex" ) , 
1130+       sentValue , 
1131+       [ SOL_PRICE_FEED_ID ,  TON_PRICE_FEED_ID ,  PYTH_PRICE_FEED_ID ,  USDT_PRICE_FEED_ID ] , 
1132+       HERMES_SOL_UNIQUE_PUBLISH_TIME , 
1133+       HERMES_SOL_UNIQUE_PUBLISH_TIME , 
1134+       deployer . address , 
1135+       CUSTOM_PAYLOAD , 
1136+     ) ; 
1137+ 
1138+     // Verify transaction success and message count 
1139+     expect ( result . transactions ) . toHaveTransaction ( { 
1140+       from : deployer . address , 
1141+       to : pythTest . address , 
1142+       success : true , 
1143+       outMessagesCount : 1 , 
1144+     } ) ; 
1145+ 
1146+     // Get the output message 
1147+     const  outMessage  =  result . transactions [ 1 ] . outMessages . values ( ) [ 0 ] ; 
1148+ 
1149+     // Verify excess value is returned 
1150+     expect ( 
1151+       ( outMessage . info  as  CommonMessageInfoInternal ) . value . coins , 
1152+     ) . toBeGreaterThan ( 0 ) ; 
1153+ 
1154+     const  cs  =  outMessage . body . beginParse ( ) ; 
1155+ 
1156+     // Verify message header 
1157+     const  op  =  cs . loadUint ( 32 ) ; 
1158+     expect ( op ) . toBe ( 5 ) ;  // OP_PARSE_PRICE_FEED_UPDATES 
1159+ 
1160+     // Verify number of price feeds 
1161+     const  numPriceFeeds  =  cs . loadUint ( 8 ) ; 
1162+     expect ( numPriceFeeds ) . toBe ( 4 ) ;  // We expect SOL, TON, PYTH and USDT price feeds 
1163+ 
1164+     // Load and verify price feeds 
1165+     const  priceFeedsCell  =  cs . loadRef ( ) ; 
1166+     let  currentCell  =  priceFeedsCell ; 
1167+ 
1168+     // First price feed (SOL) 
1169+     const  solCs  =  currentCell . beginParse ( ) ; 
1170+     const  solPriceId  = 
1171+       "0x"  +  solCs . loadUintBig ( 256 ) . toString ( 16 ) . padStart ( 64 ,  "0" ) ; 
1172+     expect ( solPriceId ) . toBe ( SOL_PRICE_FEED_ID ) ; 
1173+ 
1174+     const  solPriceFeedCell  =  solCs . loadRef ( ) ; 
1175+     const  solPriceFeedSlice  =  solPriceFeedCell . beginParse ( ) ; 
1176+ 
1177+     // Verify SOL current price 
1178+     const  solCurrentPriceCell  =  solPriceFeedSlice . loadRef ( ) ; 
1179+     const  solCurrentPrice  =  solCurrentPriceCell . beginParse ( ) ; 
1180+     expect ( solCurrentPrice . loadInt ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_PRICE ) ; 
1181+     expect ( solCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_CONF ) ; 
1182+     expect ( solCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_SOL_UNIQUE_EXPO ) ; 
1183+     expect ( solCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_PUBLISH_TIME ) ; 
1184+ 
1185+     // Verify sender address 
1186+     const  senderAddress  =  cs . loadAddress ( ) ; 
1187+     expect ( senderAddress ?. toString ( ) ) . toBe ( 
1188+       deployer . getSender ( ) . address . toString ( ) , 
1189+     ) ; 
1190+ 
1191+     // Verify custom payload 
1192+     const  customPayloadCell  =  cs . loadRef ( ) ; 
1193+     const  customPayloadSlice  =  customPayloadCell . beginParse ( ) ; 
1194+     const  receivedPayload  =  Buffer . from ( 
1195+       customPayloadSlice . loadBuffer ( CUSTOM_PAYLOAD . length ) , 
1196+     ) ; 
1197+     expect ( receivedPayload . toString ( "hex" ) ) . toBe ( 
1198+       CUSTOM_PAYLOAD . toString ( "hex" ) , 
1199+     ) ; 
1200+   } ) ; 
1201+ 
11131202  it ( "should successfully parse unique price feed updates" ,  async  ( )  =>  { 
11141203    await  deployContract ( ) ; 
11151204    await  updateGuardianSets ( pythTest ,  deployer ) ; 
@@ -1229,6 +1318,85 @@ describe("PythTest", () => {
12291318    ) ; 
12301319  } ) ; 
12311320
1321+   it ( "should successfully parse unique price feed updates with more than 3 price feed ids" ,  async  ( )  =>  { 
1322+     await  deployContract ( ) ; 
1323+     await  updateGuardianSets ( pythTest ,  deployer ) ; 
1324+ 
1325+     const  sentValue  =  toNano ( "1" ) ; 
1326+     const  result  =  await  pythTest . sendParseUniquePriceFeedUpdates ( 
1327+       deployer . getSender ( ) , 
1328+       Buffer . from ( HERMES_SOL_TON_PYTH_USDT_UPDATE ,  "hex" ) , 
1329+       sentValue , 
1330+       [ SOL_PRICE_FEED_ID ,  TON_PRICE_FEED_ID ,  PYTH_PRICE_FEED_ID ,  USDT_PRICE_FEED_ID ] , 
1331+       HERMES_SOL_UNIQUE_PUBLISH_TIME , 
1332+       60 , 
1333+       deployer . address , 
1334+       CUSTOM_PAYLOAD , 
1335+     ) ; 
1336+ 
1337+     // Verify transaction success and message count 
1338+     expect ( result . transactions ) . toHaveTransaction ( { 
1339+       from : deployer . address , 
1340+       to : pythTest . address , 
1341+       success : true , 
1342+       outMessagesCount : 1 , 
1343+     } ) ; 
1344+ 
1345+     // Get the output message 
1346+     const  outMessage  =  result . transactions [ 1 ] . outMessages . values ( ) [ 0 ] ; 
1347+ 
1348+     // Verify excess value is returned 
1349+     expect ( 
1350+       ( outMessage . info  as  CommonMessageInfoInternal ) . value . coins , 
1351+     ) . toBeGreaterThan ( 0 ) ; 
1352+ 
1353+     const  cs  =  outMessage . body . beginParse ( ) ; 
1354+ 
1355+     // Verify message header 
1356+     const  op  =  cs . loadUint ( 32 ) ; 
1357+     expect ( op ) . toBe ( 6 ) ;  // OP_PARSE_UNIQUE_PRICE_FEED_UPDATES 
1358+ 
1359+     // Verify number of price feeds 
1360+     const  numPriceFeeds  =  cs . loadUint ( 8 ) ; 
1361+     expect ( numPriceFeeds ) . toBe ( 4 ) ;  // We expect SOL, TON, PYTH and USDT price feeds 
1362+ 
1363+     // Load and verify price feeds 
1364+     const  priceFeedsCell  =  cs . loadRef ( ) ; 
1365+     let  currentCell  =  priceFeedsCell ; 
1366+ 
1367+     // First price feed (SOL) 
1368+     const  solCs  =  currentCell . beginParse ( ) ; 
1369+     const  solPriceId  = 
1370+       "0x"  +  solCs . loadUintBig ( 256 ) . toString ( 16 ) . padStart ( 64 ,  "0" ) ; 
1371+     expect ( solPriceId ) . toBe ( SOL_PRICE_FEED_ID ) ; 
1372+ 
1373+     const  solPriceFeedCell  =  solCs . loadRef ( ) ; 
1374+     const  solPriceFeedSlice  =  solPriceFeedCell . beginParse ( ) ; 
1375+ 
1376+     // Verify SOL current price 
1377+     const  solCurrentPriceCell  =  solPriceFeedSlice . loadRef ( ) ; 
1378+     const  solCurrentPrice  =  solCurrentPriceCell . beginParse ( ) ; 
1379+     expect ( solCurrentPrice . loadInt ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_PRICE ) ; 
1380+     expect ( solCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_CONF ) ; 
1381+     expect ( solCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_SOL_UNIQUE_EXPO ) ; 
1382+     expect ( solCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_PUBLISH_TIME ) ; 
1383+     // Verify sender address 
1384+     const  senderAddress  =  cs . loadAddress ( ) ; 
1385+     expect ( senderAddress ?. toString ( ) ) . toBe ( 
1386+       deployer . getSender ( ) . address . toString ( ) , 
1387+     ) ; 
1388+ 
1389+     // Verify custom payload 
1390+     const  customPayloadCell  =  cs . loadRef ( ) ; 
1391+     const  customPayloadSlice  =  customPayloadCell . beginParse ( ) ; 
1392+     const  receivedPayload  =  Buffer . from ( 
1393+       customPayloadSlice . loadBuffer ( CUSTOM_PAYLOAD . length ) , 
1394+     ) ; 
1395+     expect ( receivedPayload . toString ( "hex" ) ) . toBe ( 
1396+       CUSTOM_PAYLOAD . toString ( "hex" ) , 
1397+     ) ; 
1398+   } ) ; 
1399+ 
12321400  it ( "should fail to parse invalid price feed updates" ,  async  ( )  =>  { 
12331401    await  deployContract ( ) ; 
12341402    await  updateGuardianSets ( pythTest ,  deployer ) ; 
0 commit comments