From ba23e5067f2ce5e319241cc4cb1cea6585c199b8 Mon Sep 17 00:00:00 2001 From: rsoeldner Date: Tue, 2 Apr 2024 18:09:57 +0200 Subject: [PATCH] fix hyperlane gas tests (#1359) * fix hyperlane gas tests --- src/Pact/GasModel/GasTests.hs | 3 ++- src/Pact/Native.hs | 10 ++++++++-- tests/GasModelSpec.hs | 9 ++++++--- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Pact/GasModel/GasTests.hs b/src/Pact/GasModel/GasTests.hs index 43216e5d9..e67a5e9b3 100644 --- a/src/Pact/GasModel/GasTests.hs +++ b/src/Pact/GasModel/GasTests.hs @@ -42,7 +42,8 @@ import Pact.JSON.Legacy.Value -- | Gas benchmark tests for Pact native functions allNatives :: [NativeDefName] -allNatives = map fst (concatMap snd natives) <> nonNatives +allNatives = map fst (concatMap snd pact412Natives) <> nonNatives + -- | Non-native concepts to benchmark nonNatives :: [NativeDefName] diff --git a/src/Pact/Native.hs b/src/Pact/Native.hs index 29c30b6d0..7b45b7a94 100644 --- a/src/Pact/Native.hs +++ b/src/Pact/Native.hs @@ -21,6 +21,9 @@ module Pact.Native ( natives , nativeDefs + , hyperlaneDefs + , hyperlaneAmendedDefs + , pact412Natives , pact412NativeDefs , moduleToMap , distinctDef @@ -143,10 +146,13 @@ natives = -- | Production native modules as a dispatch map. nativeDefs :: HM.HashMap Text Ref -nativeDefs = mconcat $ map moduleToMap (hyperlaneDefs:natives) +nativeDefs = mconcat $ map moduleToMap natives + +pact412Natives :: [NativeModule] +pact412Natives = hyperlaneAmendedDefs:natives pact412NativeDefs :: HM.HashMap Text Ref -pact412NativeDefs = mconcat $ map moduleToMap $ hyperlaneAmendedDefs:natives +pact412NativeDefs = foldMap moduleToMap pact412Natives moduleToMap :: NativeModule -> HM.HashMap Text Ref moduleToMap = HM.fromList . map (asString *** Direct) . snd diff --git a/tests/GasModelSpec.hs b/tests/GasModelSpec.hs index cbfc67953..492886db7 100644 --- a/tests/GasModelSpec.hs +++ b/tests/GasModelSpec.hs @@ -89,9 +89,10 @@ untestedNativesCheck = do , "verify-spv" , "public-chain-data" , "dec" + , "hyperlane-decode-token-message" + , "hyperlane-token-erc20","hyperlane-token-msg" , "list" , "continue" - , "hyperlane-decode-token-message" ]) allGasTestsAndGoldenShouldPass :: Spec @@ -138,14 +139,16 @@ goldenSizeOfPactValues = do allNativesInGasTable :: Spec allNativesInGasTable = do it "all native functions should be in gas table" $ do - let justNatives = map (asString . fst) (concatMap snd natives) + let justNatives = map (asString . fst) (concatMap snd pact412Natives) absent li name = case (Map.lookup name defaultGasTable) of Nothing -> name : li Just _ -> li absentNatives = foldl' absent [] justNatives (S.fromList absentNatives) `shouldBe` - (S.fromList ["CHARSET_ASCII", "CHARSET_LATIN1", "public-chain-data", "list"]) + (S.fromList ["CHARSET_ASCII", "CHARSET_LATIN1" + ,"hyperlane-token-erc20", "hyperlane-token-msg" + ,"public-chain-data", "list"]) -- | Use this to run a single named test. _runNative :: NativeDefName -> IO (Maybe [(T.Text,Gas)])