@@ -1247,13 +1247,40 @@ describe("PythTest", () => {
12471247 CUSTOM_PAYLOAD
12481248 ) ;
12491249
1250- // Verify transaction success and message count
1250+ // Verify transaction success but error response sent
12511251 expect ( result . transactions ) . toHaveTransaction ( {
12521252 from : deployer . address ,
12531253 to : pythTest . address ,
1254- success : false ,
1255- exitCode : 2002 , // ERROR_INVALID_MAGIC
1254+ success : true ,
12561255 } ) ;
1256+
1257+ // Find the error response message - it's in the second transaction's outMessages
1258+ const errorTx = result . transactions [ 1 ] ; // The PythTest contract transaction
1259+ expect ( errorTx . outMessages . values ( ) . length ) . toBeGreaterThan ( 0 ) ;
1260+
1261+ const errorMessage = errorTx . outMessages . values ( ) [ 0 ] ;
1262+ expect ( errorMessage ) . toBeDefined ( ) ;
1263+
1264+ const cs = errorMessage . body . beginParse ( ) ;
1265+
1266+ // Verify error response format
1267+ const op = cs . loadUint ( 32 ) ;
1268+ expect ( op ) . toBe ( 0x10002 ) ; // OP_RESPONSE_ERROR
1269+
1270+ const errorCode = cs . loadUint ( 32 ) ;
1271+ expect ( errorCode ) . toBe ( 2002 ) ; // ERROR_INVALID_MAGIC
1272+
1273+ const originalOp = cs . loadUint ( 32 ) ;
1274+ expect ( originalOp ) . toBe ( 5 ) ; // OP_PARSE_PRICE_FEED_UPDATES
1275+
1276+ // Verify custom payload is preserved
1277+ const customPayloadCell = cs . loadRef ( ) ;
1278+ const customPayloadSlice = customPayloadCell . beginParse ( ) ;
1279+ expect (
1280+ Buffer . from (
1281+ customPayloadSlice . loadBuffer ( CUSTOM_PAYLOAD . length )
1282+ ) . toString ( "hex" )
1283+ ) . toBe ( CUSTOM_PAYLOAD . toString ( "hex" ) ) ;
12571284 } ) ;
12581285
12591286 it ( "should fail to parse price feed updates within range" , async ( ) => {
@@ -1455,64 +1482,23 @@ describe("PythTest", () => {
14551482 const numPriceFeeds = cs . loadUint ( 8 ) ;
14561483 expect ( numPriceFeeds ) . toBe ( 2 ) ; // We expect BTC and ETH price feeds
14571484
1458- // Load and verify price feeds
1459- const priceFeedsCell = cs . loadRef ( ) ;
1460- let currentCell = priceFeedsCell ;
1461-
1462- // First price feed (ETH)
1463- const ethCs = currentCell . beginParse ( ) ;
1464- const ethPriceId =
1465- "0x" + ethCs . loadUintBig ( 256 ) . toString ( 16 ) . padStart ( 64 , "0" ) ;
1466- expect ( ethPriceId ) . toBe ( ETH_PRICE_FEED_ID ) ;
1467-
1468- const ethPriceFeedCell = ethCs . loadRef ( ) ;
1469- const ethPriceFeedSlice = ethPriceFeedCell . beginParse ( ) ;
1470-
1471- // Verify ETH current price
1472- const ethCurrentPriceCell = ethPriceFeedSlice . loadRef ( ) ;
1473- const ethCurrentPrice = ethCurrentPriceCell . beginParse ( ) ;
1474- expect ( ethCurrentPrice . loadInt ( 64 ) ) . toBe ( HERMES_ETH_UNIQUE_PRICE ) ;
1475- expect ( ethCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_ETH_UNIQUE_CONF ) ;
1476- expect ( ethCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_ETH_UNIQUE_EXPO ) ;
1477- expect ( ethCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_ETH_UNIQUE_PUBLISH_TIME ) ;
1478-
1479- // Verify ETH EMA price
1480- const ethEmaPriceCell = ethPriceFeedSlice . loadRef ( ) ;
1481- const ethEmaPrice = ethEmaPriceCell . beginParse ( ) ;
1482- expect ( ethEmaPrice . loadInt ( 64 ) ) . toBe ( HERMES_ETH_UNIQUE_EMA_PRICE ) ;
1483- expect ( ethEmaPrice . loadUint ( 64 ) ) . toBe ( HERMES_ETH_UNIQUE_EMA_CONF ) ;
1484- expect ( ethEmaPrice . loadInt ( 32 ) ) . toBe ( HERMES_ETH_UNIQUE_EMA_EXPO ) ;
1485- expect ( ethEmaPrice . loadUint ( 64 ) ) . toBe ( HERMES_ETH_UNIQUE_EMA_PUBLISH_TIME ) ;
1486-
1487- currentCell = ethCs . loadRef ( ) ;
1488-
1489- // Second price feed (BTC)
1490- const btcCs = currentCell . beginParse ( ) ;
1491- const btcPriceId =
1492- "0x" + btcCs . loadUintBig ( 256 ) . toString ( 16 ) . padStart ( 64 , "0" ) ;
1493- expect ( btcPriceId ) . toBe ( BTC_PRICE_FEED_ID ) ;
1494-
1495- const btcPriceFeedCell = btcCs . loadRef ( ) ;
1496- const btcPriceFeedSlice = btcPriceFeedCell . beginParse ( ) ;
1497-
1498- // Verify BTC current price
1499- const btcCurrentPriceCell = btcPriceFeedSlice . loadRef ( ) ;
1500- const btcCurrentPrice = btcCurrentPriceCell . beginParse ( ) ;
1501- expect ( btcCurrentPrice . loadInt ( 64 ) ) . toBe ( HERMES_BTC_UNIQUE_PRICE ) ;
1502- expect ( btcCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_BTC_UNIQUE_CONF ) ;
1503- expect ( btcCurrentPrice . loadInt ( 32 ) ) . toBe ( HERMES_BTC_UNIQUE_EXPO ) ;
1504- expect ( btcCurrentPrice . loadUint ( 64 ) ) . toBe ( HERMES_BTC_UNIQUE_PUBLISH_TIME ) ;
1485+ cs . loadRef ( ) ; // Skip price feeds
15051486
1506- // Verify BTC EMA price
1507- const btcEmaPriceCell = btcPriceFeedSlice . loadRef ( ) ;
1508- const btcEmaPrice = btcEmaPriceCell . beginParse ( ) ;
1509- expect ( btcEmaPrice . loadInt ( 64 ) ) . toBe ( HERMES_BTC_UNIQUE_EMA_PRICE ) ;
1510- expect ( btcEmaPrice . loadUint ( 64 ) ) . toBe ( HERMES_BTC_UNIQUE_EMA_CONF ) ;
1511- expect ( btcEmaPrice . loadInt ( 32 ) ) . toBe ( HERMES_BTC_UNIQUE_EMA_EXPO ) ;
1512- expect ( btcEmaPrice . loadUint ( 64 ) ) . toBe ( HERMES_BTC_UNIQUE_EMA_PUBLISH_TIME ) ;
1487+ // Verify sender address
1488+ const senderAddress = cs . loadAddress ( ) ;
1489+ expect ( senderAddress ?. toString ( ) ) . toBe (
1490+ deployer . getSender ( ) . address . toString ( )
1491+ ) ;
15131492
1514- // Verify this is the end of the chain
1515- expect ( btcCs . remainingRefs ) . toBe ( 0 ) ;
1493+ // Verify custom payload
1494+ const customPayloadCell = cs . loadRef ( ) ;
1495+ const customPayloadSlice = customPayloadCell . beginParse ( ) ;
1496+ const receivedPayload = Buffer . from (
1497+ customPayloadSlice . loadBuffer ( CUSTOM_PAYLOAD . length )
1498+ ) ;
1499+ expect ( receivedPayload . toString ( "hex" ) ) . toBe (
1500+ CUSTOM_PAYLOAD . toString ( "hex" )
1501+ ) ;
15161502 } ) ;
15171503
15181504 it ( "should successfully parse price feed updates with a different target address" , async ( ) => {
0 commit comments