@@ -54,6 +54,10 @@ import {
54
54
HERMES_SOL_UNIQUE_PRICE ,
55
55
HERMES_SOL_UNIQUE_CONF ,
56
56
HERMES_SOL_UNIQUE_EXPO ,
57
+ HERMES_USDT_UNIQUE_PRICE ,
58
+ HERMES_USDT_UNIQUE_EXPO ,
59
+ HERMES_USDT_UNIQUE_CONF ,
60
+ HERMES_USDT_UNIQUE_PUBLISH_TIME ,
57
61
} from "./utils/pyth" ;
58
62
import { GUARDIAN_SET_0 , MAINNET_UPGRADE_VAAS } from "./utils/wormhole" ;
59
63
import { DataSource } from "@pythnetwork/xc-admin-common" ;
@@ -1187,6 +1191,37 @@ describe("PythTest", () => {
1187
1191
expect ( solCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_SOL_UNIQUE_EXPO ) ;
1188
1192
expect ( solCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_PUBLISH_TIME ) ;
1189
1193
1194
+ // Move through TON and PYTH price feeds to reach USDT
1195
+ currentCell = solCs . loadRef ( ) ; // Move to TON
1196
+ const tonCs = currentCell . beginParse ( ) ;
1197
+ tonCs . loadUintBig ( 256 ) ; // Skip TON price ID
1198
+ tonCs . loadRef ( ) ; // Skip TON price data
1199
+
1200
+ currentCell = tonCs . loadRef ( ) ; // Move to PYTH
1201
+ const pythCs = currentCell . beginParse ( ) ;
1202
+ pythCs . loadUintBig ( 256 ) ; // Skip PYTH price ID
1203
+ pythCs . loadRef ( ) ; // Skip PYTH price data
1204
+
1205
+ currentCell = pythCs . loadRef ( ) ; // Move to USDT
1206
+ const usdtCs = currentCell . beginParse ( ) ;
1207
+ const usdtPriceId =
1208
+ "0x" + usdtCs . loadUintBig ( 256 ) . toString ( 16 ) . padStart ( 64 , "0" ) ;
1209
+ expect ( usdtPriceId ) . toBe ( USDT_PRICE_FEED_ID ) ;
1210
+
1211
+ const usdtPriceFeedCell = usdtCs . loadRef ( ) ;
1212
+ const usdtPriceFeedSlice = usdtPriceFeedCell . beginParse ( ) ;
1213
+
1214
+ // Verify USDT current price
1215
+ const usdtCurrentPriceCell = usdtPriceFeedSlice . loadRef ( ) ;
1216
+ const usdtCurrentPrice = usdtCurrentPriceCell . beginParse ( ) ;
1217
+ expect ( usdtCurrentPrice . loadInt ( 64 ) ) . toBe ( HERMES_USDT_UNIQUE_PRICE ) ;
1218
+ expect ( usdtCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_USDT_UNIQUE_CONF ) ;
1219
+ expect ( usdtCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_USDT_UNIQUE_EXPO ) ;
1220
+ expect ( usdtCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_USDT_UNIQUE_PUBLISH_TIME ) ;
1221
+
1222
+ // Verify this is the end of the chain
1223
+ expect ( usdtCs . remainingRefs ) . toBe ( 0 ) ;
1224
+
1190
1225
// Verify sender address
1191
1226
const senderAddress = cs . loadAddress ( ) ;
1192
1227
expect ( senderAddress ?. toString ( ) ) . toBe (
@@ -1390,6 +1425,38 @@ describe("PythTest", () => {
1390
1425
expect ( solCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_CONF ) ;
1391
1426
expect ( solCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_SOL_UNIQUE_EXPO ) ;
1392
1427
expect ( solCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_SOL_UNIQUE_PUBLISH_TIME ) ;
1428
+
1429
+ // Move through TON and PYTH price feeds to reach USDT
1430
+ currentCell = solCs . loadRef ( ) ; // Move to TON
1431
+ const tonCs = currentCell . beginParse ( ) ;
1432
+ tonCs . loadUintBig ( 256 ) ; // Skip TON price ID
1433
+ tonCs . loadRef ( ) ; // Skip TON price data
1434
+
1435
+ currentCell = tonCs . loadRef ( ) ; // Move to PYTH
1436
+ const pythCs = currentCell . beginParse ( ) ;
1437
+ pythCs . loadUintBig ( 256 ) ; // Skip PYTH price ID
1438
+ pythCs . loadRef ( ) ; // Skip PYTH price data
1439
+
1440
+ currentCell = pythCs . loadRef ( ) ; // Move to USDT
1441
+ const usdtCs = currentCell . beginParse ( ) ;
1442
+ const usdtPriceId =
1443
+ "0x" + usdtCs . loadUintBig ( 256 ) . toString ( 16 ) . padStart ( 64 , "0" ) ;
1444
+ expect ( usdtPriceId ) . toBe ( USDT_PRICE_FEED_ID ) ;
1445
+
1446
+ const usdtPriceFeedCell = usdtCs . loadRef ( ) ;
1447
+ const usdtPriceFeedSlice = usdtPriceFeedCell . beginParse ( ) ;
1448
+
1449
+ // Verify USDT current price
1450
+ const usdtCurrentPriceCell = usdtPriceFeedSlice . loadRef ( ) ;
1451
+ const usdtCurrentPrice = usdtCurrentPriceCell . beginParse ( ) ;
1452
+ expect ( usdtCurrentPrice . loadInt ( 64 ) ) . toBe ( HERMES_USDT_UNIQUE_PRICE ) ;
1453
+ expect ( usdtCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_USDT_UNIQUE_CONF ) ;
1454
+ expect ( usdtCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_USDT_UNIQUE_EXPO ) ;
1455
+ expect ( usdtCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_USDT_UNIQUE_PUBLISH_TIME ) ;
1456
+
1457
+ // Verify this is the end of the chain
1458
+ expect ( usdtCs . remainingRefs ) . toBe ( 0 ) ;
1459
+
1393
1460
// Verify sender address
1394
1461
const senderAddress = cs . loadAddress ( ) ;
1395
1462
expect ( senderAddress ?. toString ( ) ) . toBe (
0 commit comments