-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from kadena-io/jose/module-hashing
Module hashing + Defconst eval
- Loading branch information
Showing
22 changed files
with
911 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
(env-data {'k:1}) | ||
|
||
(defun check-hash-equivalent (mstring:string h:string) | ||
(expect (concat ["Hash of module ", mstring, " matches"]) (at "hash" (describe-module mstring)) h) | ||
) | ||
|
||
(module m m-gov | ||
(defcap m-gov () true) | ||
|
||
(defconst fconst:integer (read-integer "k")) | ||
|
||
(defun mdfn () 1) | ||
|
||
(defpact mdpact () | ||
(step 1)) | ||
|
||
(defschema sc a:integer) | ||
|
||
(deftable mdtbl:{sc}) | ||
) | ||
|
||
; base case | ||
(check-hash-equivalent "m" "QCLU54Co9PbQqiqFz1F3M-pPgdn59ANGIG7bwNVFAJk") | ||
|
||
(env-data {'k:2}) | ||
(module m m-gov | ||
(defcap m-gov () true) | ||
|
||
(defconst fconst:integer (read-integer "k")) | ||
|
||
(defun mdfn () 1) | ||
|
||
(defpact mdpact () | ||
(step 1)) | ||
|
||
(defschema sc a:integer) | ||
|
||
(deftable mdtbl:{sc}) | ||
) | ||
|
||
|
||
; Defconst changed, ensure hash changed | ||
(check-hash-equivalent "m" "83c6a-9Hmv9yHOkaY1Y2LmHoHvXLWYc_lQ-Oacg8URw") | ||
|
||
(module m m-gov | ||
(defcap m-gov () true) | ||
|
||
(defconst fconst:integer (read-integer "k")) | ||
|
||
(defun mdfn () 2) | ||
|
||
(defpact mdpact () | ||
(step 1)) | ||
|
||
(defschema sc a:integer) | ||
|
||
(deftable mdtbl:{sc}) | ||
) | ||
|
||
|
||
; Basic code changed: hash should change | ||
(check-hash-equivalent "m" "WhYWXrM3oUwXRaiPela_j7d2nF5snW5SPjGUOuuJu7c") | ||
|
||
; Modules, interfaces and deps | ||
(module n gg | ||
(use m) | ||
(defcap gg () true) | ||
|
||
(defconst nfconst:integer (read-integer "k")) | ||
|
||
(defun nf () (mdfn)) | ||
|
||
) | ||
|
||
(check-hash-equivalent "n" "v30ra86hQ35kT1k8pdXnGsGU434VD7Ysa7smYhHFPs0") | ||
|
||
; Update dependent module, ensure hash changes | ||
(module m m-gov | ||
(defcap m-gov () true) | ||
|
||
(defconst fconst:integer (read-integer "k")) | ||
|
||
(defun mdfn () 3) | ||
|
||
(defpact mdpact () | ||
(step 1)) | ||
|
||
(defschema sc a:integer) | ||
|
||
(deftable mdtbl:{sc}) | ||
) | ||
|
||
; n has not changed, but m has, it should change the dep | ||
(module n gg | ||
(use m) | ||
(defcap gg () true) | ||
|
||
(defconst nfconst:integer (read-integer "k")) | ||
|
||
(defun nf () (mdfn)) | ||
|
||
) | ||
|
||
; m changed, hash should have changed | ||
(check-hash-equivalent "m" "BVrxWuHbjy9heR9AhAZnbusKvSKiyzrEYt8_0LCBRqs") | ||
|
||
; n did not change, but the dependency hash changed, so it should also change the hash | ||
(check-hash-equivalent "n" "ETUjfmMviiXCyZYxJLzk1uXBQFizGizyqPGz1XIt1lA") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.