Skip to content

Commit bd458a0

Browse files
committed
fmt
1 parent 9153dad commit bd458a0

3 files changed

Lines changed: 45 additions & 15 deletions

File tree

‎test/src/concrete/PythFork.t.sol‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: LicenseRef-DCL-1.0
2+
// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd
3+
pragma solidity =0.8.25;
4+
5+
import {Test, console2} from "forge-std/Test.sol";
6+
import {IPyth} from "pyth-sdk/IPyth.sol";
7+
8+
contract PythForkTest is Test {
9+
IPyth constant PRICE_FEED_CONTRACT_BASE = IPyth(0x8250f4aF4B972684F7b336503E2D6dFeDeB1487a);
10+
11+
bytes32 constant feed = 0x82c59e36a8e0247e15283748d6cd51f5fa1019d73fbf3ab6d927e17d9e357a7f;
12+
13+
function testPythFor() external {
14+
vm.createSelectFork("https://base-mainnet.g.alchemy.com/v2/y3BXawVv5uuP_g8BaDlKbKoTBGHo9zD9", 39362994);
15+
console2.log("current block : ", block.number);
16+
17+
bytes[] memory updateData = new bytes[](1);
18+
updateData[0] =
19+
hex"504e41550100000003b801000000040d00159e6b960c6392d97ae8705a333964b25f2f3b2b2cd841fba8af81aa1c350daf368dd056546714c311c8e4628ab41f11b14c2ef66c01549391ca8878ad23898100039d3c0f5450fe8b546d7d3f26355bfc25df13c17fef945a254a2fee6ced0181770c6b0e0102a3218ee500809e462c7b514ef461d1ec62d9da0f626be55316dcb501040a962e83afe97b8b58a5bbedbde8b2fbdc5e8eb1b8a90b1bfcedfc3b864543d47bceb74ac46847c9f54bc902e200f7a5fd60ac7b74c489f681bb1f65958cb51b000668315fe5f8b512a84504e430940f458a3da333615c9985ea4ec9b0b32303f284104b9ff8235751798a40aa549d1f17f9c511303266449570e0450dd3cad247ab0008acb1a29b4fc10eb5a995db6ad7ddce9220211dc3b5b4eedc0f1938aa49aee73d2cda222a0b2471aeb0658873c71a9ad8591e0c0329ec7dad9c6a07a546879014000a56e408774a54835e9d4b074e7e4be818de49feb191e59ac70bea16de832df7a7307564e7d1062963a4b06f0a86063c5996f868525778beab3a96ead237887a61010b5beea51befaa3941048c8990704fd70f536eb7a4b1e9d4077082cd1e864c8b0b7ef3fd72736ea16487a26d73e4ae741376086648099b5800855d6cfe8aba6e6a010c9488fc063a6f95941bdd6752904867f9e006627cebbe884913ec701c4251b72919638539ad56b185faa297de9d9489585f9a29eff07b20eafb5a52cb654c7e81010dbdc2d481f010dabfc0283410e5426fe89f53fd668c69b6cbdc8698dc1ac3e2317f54d1fbb13abd5ac9bd77faac2fd643787129632d5ce598ef8d7014acad0d62000e1fb96a04565f0747c217748b30e6140ff4a3a0c038e0f511c8fc2fafee543d12361a8e5e821b329bd762330f3ceba0cb5f060969b91ea18d4518cf40ff78c8c8010fec3273ec5215c53922fb7cc3b4911415b92372654b2fa7a753236ba04905a6316d399ea32dc07de0cc2d1f9635e4a11280b2008c8a3e3051aa032d92d20849360110e760acc46e9ecdede1fcb4ea92f3de5aab0a9e5cd948f2b7b06357a22da872fc44154e654019b37e2c07a0611f46e8e743bb5457726ba115e7763aa5e0b9a1110111b0a0a2bc5e683767a445b6b7087f70c55e133629aefac20839ece436671aa6af3dee03d62dbdbcb0d34613b0655eb51fd4d2fe76a0f2bf13261c1a883dd2f81100693b9e8600000000001ae101faedac5851e32b9b23b5f9411a8c2bac4aae3ed4dd7b811dd1a72ea4aa71000000000a77dcee014155575600000000000f8583fb00002710adfe79e76112c350f04eea002302a3af75bf09cc0100550082c59e36a8e0247e15283748d6cd51f5fa1019d73fbf3ab6d927e17d9e357a7f00000000016039ec000000000000251cfffffffb00000000693ad57900000000693ad57900000000015f76830000000000004d460d7493f0f0082bad7458aa5c04943296ddd9366b0937026b4c51a3ba0b5567bed705b8b4b6142934c9ca49017f7876c7434dfa3eda425d7c21bb95a22cc0cc2d5c09379f239a154b2d550dff279eac7b22076439f569364336e5613b58ec013d6faec4c984ef459a6d7d744197bb2ddf66bbb461e645f665eeb19edb0618038ac520200a2d1ffa27bd00cf87a207fbccb791252b6a85a21d5602f4903d6ea116b9ce483dadbdc3831fe8cff3747f939a9d1a6bd3e8f6a3e2084f06355159c6b4c1a73b84f745894deeb5cde5411c7d4ea12b4a13ee68f3924d2a8791e1af4d0570d85f91f9ef3efc5e1673076e99a73e0fc287ccec3d7e2e6a24c9b4c1d873aa4b5dca84f7";
20+
21+
uint256 fee = PRICE_FEED_CONTRACT_BASE.getUpdateFee(updateData);
22+
console2.log("fee : ", fee);
23+
PRICE_FEED_CONTRACT_BASE.updatePriceFeeds{value: fee}(updateData);
24+
PRICE_FEED_CONTRACT_BASE.getPriceUnsafe(feed);
25+
}
26+
}

‎test/src/lib/pyth/LibPyth.getPriceFeedId.t.sol‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -183,24 +183,29 @@ contract LibPythGetPriceFeedIdTest is Test {
183183
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Crypto.XRP/USD"))
184184
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD"))
185185
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.PRE"))
186-
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.POST"))
186+
&& IntOrAString.unwrap(symbol)
187+
!= IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.COIN/USD.POST"))
187188
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.GOOG/USD"))
188189
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD"))
189190
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE"))
190-
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST"))
191+
&& IntOrAString.unwrap(symbol)
192+
!= IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST"))
191193
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.AAPL/USD"))
192194
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSFT/USD"))
193195
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD"))
194196
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.PRE"))
195-
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST"))
197+
&& IntOrAString.unwrap(symbol)
198+
!= IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.TSLA/USD.POST"))
196199
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD"))
197200
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.PRE"))
198-
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST"))
201+
&& IntOrAString.unwrap(symbol)
202+
!= IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.NVDA/USD.POST"))
199203
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.META/USD"))
200204
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.GME/USD"))
201205
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD"))
202206
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.PRE"))
203-
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST"))
207+
&& IntOrAString.unwrap(symbol)
208+
!= IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST"))
204209
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.BRK-B/USD"))
205210
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.SPLG/USD"))
206211
&& IntOrAString.unwrap(symbol) != IntOrAString.unwrap(LibIntOrAString.fromString2("Equity.US.IAU/USD"))

‎test/src/lib/pyth/LibPyth.getPriceNoOlderThan.t.sol‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,14 @@ contract LibPythGetPriceNoOlderThanTest is Test {
183183
checkPriceNoOlderThan(
184184
LibIntOrAString.fromString2("Equity.US.AMZN/USD"),
185185
LibDecimalFloat.packLossless(24 hours, 0),
186-
LibDecimalFloat.packLossless(230.26800e5, -5),
186+
LibDecimalFloat.packLossless(230.268e5, -5),
187187
LibDecimalFloat.packLossless(0.12973e5, -5)
188188
);
189189
checkPriceNoOlderThan(
190190
LibIntOrAString.fromString2("Equity.US.AMZN/USD.PRE"),
191191
LibDecimalFloat.packLossless(24 hours, 0),
192-
LibDecimalFloat.packLossless(230.83500e5, -5),
193-
LibDecimalFloat.packLossless(0.09500e5, -5)
192+
LibDecimalFloat.packLossless(230.835e5, -5),
193+
LibDecimalFloat.packLossless(0.095e5, -5)
194194
);
195195
checkPriceNoOlderThan(
196196
LibIntOrAString.fromString2("Equity.US.AMZN/USD.POST"),
@@ -249,14 +249,14 @@ contract LibPythGetPriceNoOlderThanTest is Test {
249249
checkPriceNoOlderThan(
250250
LibIntOrAString.fromString2("Equity.US.META/USD"),
251251
LibDecimalFloat.packLossless(24 hours, 0),
252-
LibDecimalFloat.packLossless(652.73000e5, -5),
253-
LibDecimalFloat.packLossless(0.44100e5, -5)
252+
LibDecimalFloat.packLossless(652.73e5, -5),
253+
LibDecimalFloat.packLossless(0.441e5, -5)
254254
);
255255
checkPriceNoOlderThan(
256256
LibIntOrAString.fromString2("Equity.US.GME/USD"),
257257
LibDecimalFloat.packLossless(24 hours, 0),
258-
LibDecimalFloat.packLossless(21.84660e5, -5),
259-
LibDecimalFloat.packLossless(0.01440e5, -5)
258+
LibDecimalFloat.packLossless(21.8466e5, -5),
259+
LibDecimalFloat.packLossless(0.0144e5, -5)
260260
);
261261
checkPriceNoOlderThan(
262262
LibIntOrAString.fromString2("Equity.US.MSTR/USD"),
@@ -273,7 +273,7 @@ contract LibPythGetPriceNoOlderThanTest is Test {
273273
checkPriceNoOlderThan(
274274
LibIntOrAString.fromString2("Equity.US.MSTR/USD.POST"),
275275
LibDecimalFloat.packLossless(24 hours, 0),
276-
LibDecimalFloat.packLossless(181.95100e5, -5),
276+
LibDecimalFloat.packLossless(181.951e5, -5),
277277
LibDecimalFloat.packLossless(0.62959e5, -5)
278278
);
279279
checkPriceNoOlderThan(
@@ -298,7 +298,7 @@ contract LibPythGetPriceNoOlderThanTest is Test {
298298
checkPriceNoOlderThan(
299299
LibIntOrAString.fromString2("Equity.US.COIN/USD"),
300300
LibDecimalFloat.packLossless(24 hours, 0),
301-
LibDecimalFloat.packLossless(268.98180e5, -5),
301+
LibDecimalFloat.packLossless(268.9818e5, -5),
302302
LibDecimalFloat.packLossless(0.20161e5, -5)
303303
);
304304
checkPriceNoOlderThan(
@@ -320,5 +320,4 @@ contract LibPythGetPriceNoOlderThanTest is Test {
320320
LibDecimalFloat.packLossless(0.05473e5, -5)
321321
);
322322
}
323-
324323
}

0 commit comments

Comments
 (0)