Skip to content

Commit

Permalink
Merge pull request #299 from kadena-io/patch/2.5.1-fix-keysets
Browse files Browse the repository at this point in the history
Patch/2.5.1 fix keysets
  • Loading branch information
Stuart Popejoy committed Nov 12, 2018
2 parents 69f89c9 + 23f31d1 commit 7c60396
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
2.5.1
---
* Fix keyset enforce of old keyset

2.5.0
---
* Pluggable gas model with simple fixed-rate implementation
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -61,9 +61,9 @@
# built documents.
#
# The short X.Y version.
version = u'2.5.0'
version = u'2.5.1'
# The full version, including alpha/beta/rc tags.
release = u'2.5.0'
release = u'2.5.1'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion docs/pact-functions.md
Expand Up @@ -283,7 +283,7 @@ Return ID if called during current pact execution, failing if not.
Obtain current pact build version.
```lisp
pact> (pact-version)
"2.5.0"
"2.5.1"
```


Expand Down
2 changes: 1 addition & 1 deletion pact.cabal
@@ -1,5 +1,5 @@
name: pact
version: 2.5.0
version: 2.5.1
synopsis: Smart contract language library and REPL
description:
Pact is a transactional, database-focused, Turing-incomplete, interpreted language for smart contracts,
Expand Down
4 changes: 2 additions & 2 deletions src/Pact/Native/Keysets.hs
Expand Up @@ -62,8 +62,8 @@ defineKeyset fi [TLitString name,TKeySet ks _] = do
old <- readRow i KeySets ksn
case old of
Nothing -> writeRow i Write KeySets ksn ks & success "Keyset defined"
Just _ -> do
runPure $ enforceKeySet i (Just ksn) ks
Just oldKs -> do
runPure $ enforceKeySet i (Just ksn) oldKs
writeRow i Write KeySets ksn ks & success "Keyset defined"
defineKeyset i as = argsError i as

Expand Down
44 changes: 44 additions & 0 deletions tests/pact/keysets.repl
Expand Up @@ -81,3 +81,47 @@
(expect "test enforce-one, keyset read in enforce-one ok" true (test-enforce-one))

(expect-failure "test enforce-one all fail" (test-enforce-one-fail))

;; test keyset redefinition

(begin-tx)
(env-data { "rotate-me": ["a"]})
(env-keys ["b"])
(define-keyset 'rotate-me (read-keyset "rotate-me"))
(commit-tx)

;; should not be able to rotate without old keys

(begin-tx)
(env-keys ["b"])
(env-data { "rotate-me2": ["b"]})
(expect-failure "should not be able to rotate without satisfying old keyset"
(define-keyset 'rotate-me (read-keyset "rotate-me2"))
)
(commit-tx)

;; should be able to rotate with old keys

(begin-tx)
(env-keys ["a"])
(env-data { "rotate-me3": ["c"] })
(define-keyset 'rotate-me (read-keyset "rotate-me3"))
(commit-tx)

;; test that keyset actually updated

(env-keys ["c"])
(enforce-keyset 'rotate-me)

;; test that rollback doesn't change keyset

(begin-tx)
(env-keys ["c"])
(env-data { "rotate-me4": ["a"]})
(define-keyset 'rotate-me (read-keyset "rotate-me4"))
(rollback-tx)

;; c should still work after rollback

(env-keys ["c"])
(enforce-keyset 'rotate-me)

0 comments on commit 7c60396

Please sign in to comment.