Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
rsoeldner committed Apr 2, 2024
1 parent 3835bc8 commit 927a496
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
7 changes: 2 additions & 5 deletions src/Pact/GasModel/GasTests.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,8 @@ import Pact.JSON.Legacy.Value

-- | Gas benchmark tests for Pact native functions
allNatives :: [NativeDefName]
allNatives = map fst (concatMap snd enhancedNatives) <> nonNatives
where
-- Note: Since we are forking natives, the `natives` list
-- does not fully capture all available natives for the tests.
enhancedNatives = hyperlaneAmendedDefs:natives
allNatives = map fst (concatMap snd pact412Natives) <> nonNatives


-- | Non-native concepts to benchmark
nonNatives :: [NativeDefName]
Expand Down
9 changes: 7 additions & 2 deletions src/Pact/Native.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
module Pact.Native
( natives
, nativeDefs
, hyperlaneDefs
, hyperlaneAmendedDefs
, pact412Natives
, pact412NativeDefs
, moduleToMap
, distinctDef
Expand Down Expand Up @@ -144,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 = foldMap moduleToMap $ hyperlaneAmendedDefs:natives
pact412NativeDefs = foldMap moduleToMap pact412Natives

moduleToMap :: NativeModule -> HM.HashMap Text Ref
moduleToMap = HM.fromList . map (asString *** Direct) . snd
Expand Down
2 changes: 1 addition & 1 deletion tests/GasModelSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ goldenSizeOfPactValues = do
allNativesInGasTable :: Spec
allNativesInGasTable = do
it "all native functions should be in gas table" $ do
let justNatives = map (asString . fst) (concatMap snd $ hyperlaneAmendedDefs:natives)
let justNatives = map (asString . fst) (concatMap snd pact412Natives)
absent li name = case (Map.lookup name defaultGasTable) of
Nothing -> name : li
Just _ -> li
Expand Down

0 comments on commit 927a496

Please sign in to comment.