Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix hyperlane gas tests #1359

Merged
merged 2 commits into from
Apr 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Pact/GasModel/GasTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
10 changes: 8 additions & 2 deletions src/Pact/Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
module Pact.Native
( natives
, nativeDefs
, hyperlaneDefs
, hyperlaneAmendedDefs
, pact412Natives
, pact412NativeDefs
, moduleToMap
, distinctDef
Expand Down Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions tests/GasModelSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 LGTM. For any future readers: these two are schemas.

,"public-chain-data", "list"])

-- | Use this to run a single named test.
_runNative :: NativeDefName -> IO (Maybe [(T.Text,Gas)])
Expand Down
Loading