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

Import full tests from github.com:Chia-Network/clvm_tools at hash 7ab… #9

Merged
merged 46 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a376c05
Import full tests from github.com:Chia-Network/clvm_tools at hash 7ab…
aqk Mar 2, 2023
f65b0ac
use 'run' rather than 'with'
prozacchiwawa Mar 2, 2023
deef2b0
fix workflow
aqk Mar 2, 2023
e275658
Merge branch 'ak.add-classic-tests' of github.com:Chia-Network/clvm_t…
aqk Mar 2, 2023
46cc63a
fix workflow
aqk Mar 2, 2023
51868eb
fix workflow
aqk Mar 2, 2023
7f75768
Merge branch 'base' into ak.add-classic-tests
aqk Mar 2, 2023
b1ea358
Only run classic tests on Ubuntu / Python 3.7 for now
aqk Mar 3, 2023
0b8b0a3
Merge branch 'ak.add-classic-tests' of github.com:Chia-Network/clvm_t…
aqk Mar 3, 2023
5e8b329
Use internal Rust implementations for opc and opd
aqk Mar 4, 2023
24b75d5
Merge branch 'base' into ak.add-classic-tests
aqk Mar 9, 2023
a328c13
Add --version to opc, etc
aqk Mar 9, 2023
e108f98
Don't print output string if empty (eg. with --version or --help)
aqk Mar 9, 2023
dabdd4e
Remove pycache files
aqk Mar 9, 2023
c1f1dde
Move classic compiler tests to dir
aqk Mar 9, 2023
b90a5a8
Add missing include files, route in call_tool
prozacchiwawa Mar 9, 2023
39af9a7
Remove generated file
aqk Mar 9, 2023
29a0c4b
Ingore ending EOL
aqk Mar 9, 2023
1486109
Fix hex decoding of invalid literals in classic compiler
aqk Mar 14, 2023
5e2bf53
Merge branch 'base' into ak.add-classic-tests
aqk Mar 17, 2023
bf1a89e
Merge branch 'base' into ak.add-classic-tests
aqk Mar 20, 2023
990fd8c
Add SyntaxErr, so invalid hex conversions can be caught
aqk Mar 22, 2023
a9e7b57
Add SyntaxErr, so invalid hex conversions can be caught
aqk Mar 22, 2023
4c57811
Merge remote-tracking branch 'chia/ak.add-classic-tests' into ak.add-…
prozacchiwawa Mar 22, 2023
96fba98
Thread SyntaxErr through the full call tree for classic compiler
aqk Mar 23, 2023
b2e67c3
Keep start quote of string constants as part of the lexical value
aqk Mar 23, 2023
55891c5
Fix test resources/tests/cmdline/tests/opc/compile_unterminated_str.txt
aqk Mar 23, 2023
c6b006f
Merge remote-tracking branch 'chia/ak.add-classic-tests' into ak.add-…
prozacchiwawa Mar 27, 2023
ed5f625
Ensure that we don't use the first char of a quoted expression becaus…
prozacchiwawa Mar 27, 2023
823cdda
Fix numeric
prozacchiwawa Mar 28, 2023
549c80a
Bring in numeric, fix running tests
prozacchiwawa Mar 28, 2023
a3169ab
Print sha256 script hash as hex
aqk Mar 28, 2023
2a51d80
Merge branch 'ak.add-classic-tests' of github.com:Chia-Network/clvm_t…
aqk Mar 28, 2023
8e6b7f9
formatting
aqk Mar 28, 2023
5801153
Change include directory to reflect directory tests are run from
aqk Mar 28, 2023
2b44de2
Change expected output of stage_2/exp-1.txt to account for injected c…
aqk Mar 28, 2023
70c5311
Adjust symbol dir to match dir tests are run from
aqk Mar 28, 2023
1c5f393
Emit table trace when -t flag is used
aqk Mar 28, 2023
648f4be
Quick, commit it
aqk Apr 3, 2023
60cdb23
Only run cmds_test.py
aqk Apr 3, 2023
d4c3363
lint
aqk Apr 3, 2023
2763f70
Update wasm build for Hex token parse error
aqk Apr 3, 2023
6547d9a
Ensure we don't unnecessarily quote the opc output
prozacchiwawa Apr 3, 2023
9a1130a
Run these from the test directory
prozacchiwawa Apr 3, 2023
058eeeb
Remove TODO comment and collapse slightly, remove a few clippy nits
prozacchiwawa Apr 3, 2023
6168084
Merge branch 'base' into ak.add-classic-tests
prozacchiwawa Apr 3, 2023
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
10 changes: 10 additions & 0 deletions .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ jobs:
cp support/recompile_check.py chia-blockchain
(cd chia-blockchain && python recompile_check.py)

- name: Test Classic command line tools with pytest
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7')
run: |
python -m pip install pytest
# This script installs the wheel built during this workflow.
python support/wheelname.py
# TODO: bring in the other tests in resources/tests/cmdline/tests besides cmds_test.py
(cd resources/tests/cmdline/tests && py.test cmds_test.py )

- name: Verify recompilation of cl21 sources
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.python, '3.7')
run: |
Expand Down Expand Up @@ -259,3 +268,4 @@ jobs:
components: rustfmt, clippy
- name: cargo test
run: cargo test

Empty file.
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(compile (if () 100 200))'
(e (i (q ()) (q (q 100)) (q (q 200))) (a))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(compile (if 0 100 200))'
(e (i (q 0) (q (q 100)) (q (q 200))) (a))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(compile (if 1 100 200))'
(e (i (q 1) (q (q 100)) (q (q 200))) (a))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(compile (if x0 100 200))'
(e (i (f (a)) (q (q 100)) (q (q 200))) (a))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(compile (if x5 100 200))'
(e (i (f (r (r (r (r (r (a))))))) (q (q 100)) (q (q 200))) (a))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if-6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(compile (if x5 (if x1 500 600) 200))'
(e (i (f (r (r (r (r (r (a))))))) (q (e (i (f (r (a))) (q (q 500)) (q (q 600))) (a))) (q (q 200))) (a))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if_1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(if 100 200 300)'
200
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if_2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(if () 200 300)'
300
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if_3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(if () x0 300)' '(200)'
300
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if_4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(if x2 x0 x1)' '(200 300 400)'
200
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/if_5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(if x2 x0 x1)' '(200 300 ())'
300
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/list-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(list x0 x1)' '((100 102) "hello")'
((100 102) "hello")
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/list-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(compile_op (list + 1 2 (+ 1 2)))'
(+ (q 1) (q 2) (q 3))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/list-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(list 100 200 (+ 300 600) 400 500)'
(100 200 900 400 500)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/list-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(list x0 100 200 300 400 500)' '(2000)'
(2000 100 200 300 400 500)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/list-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(list 100 200 300 400 500)'
(100 200 300 400 500)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/map-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(map (function (+ x0 1)) (list 100 2 3 15 20))'
(101 3 4 16 21)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/nested.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run "(+ (+ 5 x0) x1)" "(9 1000)"
1014
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run "(and (equal 400 x0) (equal 500 x1) (equal 600 x2))" "(400)"
FAILURE: first of non-cons
()
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
run "(and (equal 400 x0) (equal 500 x1) (equal 600 x2))" "(400 500)"
FAILURE: first of non-cons
()
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/quote-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(quote (+ 1 2 (+ 1 2)))'
(+ 1 2 (+ 1 2))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/quote-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(quote (+ 1 2 (unquote (+ 1 2))))'
(+ 1 2 (unquote (+ 1 2)))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/compiler_001/quote-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(quote (quote (+ 1 2 (unquote (+ 1 2)) (unquote (unquote (+ 1 2))))))'
(quote (+ 1 2 (unquote (+ 1 2)) (unquote (unquote (+ 1 2)))))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run "(+ 10 20)"
30
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(- 10 5)'
5
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(- x0 5)' '(500)'
495
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run '(- 10 5 2 1)'
2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run x0 '("foobarbaz")'
"foobarbaz"
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run x3 '("junk" "junk" "junk" "foobarbaz" "junk" "junk")'
"foobarbaz"
15 changes: 15 additions & 0 deletions resources/tests/cmdline/tests/attic/mkp2taproot-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# this script creates a pay-to-taproot standard script. x0 = hidden public key; x1 = hidden script
#
# if x1 is not specified, the default "(raise)" should be used
#
# example: x0 = (pubkey_for_exp 1), x1 = (quote (raise (quote 0xdeadbeef)))
# ie. (0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb (raise 0xdeadbeef))
#
# reduce '(pubkey_for_exp 1)' => 0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb
# reduce '(wrap (quote (raise 0xdeadbeef)))' => 0x220964deadbeef
# reduce '(sha256 x0 (wrap x1))' => 0xac186394ef316cac5e1788286687802ed45b268f5440493e2123f4f80665dfcb
# reduce '(pubkey_for_exp (sha256 x0 (wrap x1)))' => 0x8bd429b60a77a026949a5fa77f76579de8679f2401c3b0eca8db8aa028884d6742b840f513e2faefbd379ceeeb7b5996
# reduce '(point_add x0 (pubkey_for_exp (sha256 x0 (wrap x1))))' => 0x98360c4f1e6c01c8600b80595d34ef91c8dd17e82e0df7638c2a181de1333da1a46f0353029417ff5b6ccaa6767836d2
#
reduce -s schemas.compiler_001 '(list #e (function (function (if x1 (assert (eq_atom x0 (point_add x3 (pubkey_for_exp (sha256 x3 (wrap x1))))) (e x1 x2)) (cons (list #aggsig x0 (sha256 (wrap x2))) (e x2 x3))))) (list #cons (point_add x0 (pubkey_for_exp (sha256 x0 (wrap x1)))) (list #args)))' '(0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb (quote 0xdeadbeefdeadbeef))'
(e (quote (e (if_op (first (rest (args))) (quote (e (if_op (eq_atom (first (args)) (point_add (first (rest (rest (rest (args))))) (pubkey_for_exp (sha256 (first (rest (rest (rest (args))))) (wrap (first (rest (args)))))))) (quote (e (first (rest (args))) (first (rest (rest (args)))))) (quote (raise))) (args))) (quote (cons (cons (quote 80) (cons (first (args)) (cons (sha256 (wrap (first (rest (rest (args)))))) (quote ())))) (e (first (rest (rest (args)))) (first (rest (rest (rest (args))))))))) (args))) (cons 0x01031383a372ae073bae6820b487550a7bcb78ae8359daf3db831fe50bda77e7ede389de3a636c44e62841cdc6c38286 (args)))
16 changes: 16 additions & 0 deletions resources/tests/cmdline/tests/attic/p2taproot-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# x0, x1, x2 are passed in, then renamed to x1, x2 and x3 so x0 can be a constant used by both paths
#
# taproot case
# x0 = publicly revealed key (constant)
# x1 = hidden script (which is run to enumerate conditions)
# x2 = solution to hidden script
# x3 = hidden public key
#
# regular case
# x0 = publicly revealed key (constant)
# x1 = null
# x2 = signed solution script (which is run to enumerate conditions)
# x3 = solution to x2
#
reduce -s schemas.compiler_001 '(e (quote (e (if_op (first (rest (args))) (quote (e (if_op (eq_atom (first (args)) (point_add (first (rest (rest (rest (args))))) (pubkey_for_exp (sha256 (first (rest (rest (rest (args))))) (wrap (first (rest (args)))))))) (quote (e (first (rest (args))) (first (rest (rest (args)))))) (quote (raise))) (args))) (quote (cons (cons (quote 80) (cons (first (args)) (cons (sha256 (wrap (first (rest (rest (args)))))) (quote ())))) (e (first (rest (rest (args)))) (first (rest (rest (rest (args))))))))) (args))) (cons 0x01031383a372ae073bae6820b487550a7bcb78ae8359daf3db831fe50bda77e7ede389de3a636c44e62841cdc6c38286 (args)))' '(() (quote (300 400 500)) ())'
((80 0x01031383a372ae073bae6820b487550a7bcb78ae8359daf3db831fe50bda77e7ede389de3a636c44e62841cdc6c38286 0x8d459103c42018689bdc9fe216cc33d31610f9a303f96dc460e9720b81c00d13) 300 400 500)
16 changes: 16 additions & 0 deletions resources/tests/cmdline/tests/attic/p2taproot-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# x0, x1, x2 are passed in, then renamed to x1, x2 and x3 so x0 can be a constant used by both paths
#
# taproot case
# x0 = publicly revealed key (constant)
# x1 = hidden script (which is run to enumerate conditions)
# x2 = solution to hidden script
# x3 = hidden public key
#
# regular case
# x0 = publicly revealed key (constant)
# x1 = null
# x2 = signed solution script (which is run to enumerate conditions)
# x3 = solution to x2
#
reduce -s schemas.compiler_001 '(e (quote (e (if_op (first (rest (args))) (quote (e (if_op (eq_atom (first (args)) (point_add (first (rest (rest (rest (args))))) (pubkey_for_exp (sha256 (first (rest (rest (rest (args))))) (wrap (first (rest (args)))))))) (quote (e (first (rest (args))) (first (rest (rest (args)))))) (quote (raise))) (args))) (quote (cons (cons (quote 80) (cons (first (args)) (cons (sha256 (wrap (first (rest (rest (args)))))) (quote ())))) (e (first (rest (rest (args)))) (first (rest (rest (rest (args))))))))) (args))) (cons 0x01031383a372ae073bae6820b487550a7bcb78ae8359daf3db831fe50bda77e7ede389de3a636c44e62841cdc6c38286 (args)))' '((quote 0xdeadbeefdeadbeef) () 0x97f1d3a73197d7942695638c4fa9ac0fc3688c4f9774b905a14e3a3f171bac586c55e83ff97a1aeffb3af00adb22c6bb)'
0xdeadbeefdeadbeef
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/simple-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
opc -s schemas.v0_0_2 '(((equal (sha256 x0) 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855)) (reduce x0 x2))'
2221230822094080e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855230a4042
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/simple-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
opd -s schemas.v0_0_2 2221230822094080e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855230a4042
(((equal (sha256 x0) 0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855)) (reduce x0 x2))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/simple-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
opc -s schemas.v0_0_2 "(((equal (sha256 x0) x1)) (reduce x1 x2))"
2221230822094041230a4142
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/simple-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
opd 2221230822094041230a4142
(((= (sha256 x0) x1)) (reduce x1 x2))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/bool-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(bool 0)'
(call (if_op (quote 0) (function_op (quote 1)) (function_op (quote ()))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/bool-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(bool 1000)'
(call (if_op (quote 1000) (function_op (quote 1)) (function_op (quote ()))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/bool-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(bool x0)'
(call (if_op (first (args)) (function_op (quote 1)) (function_op (quote ()))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/bool-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(bool (not x2))'
(call (if_op (call (if_op (first (rest (rest (args)))) (function_op (quote ())) (function_op (quote 1))) (args)) (function_op (quote 1)) (function_op (quote ()))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/if-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(if 0 100 200)'
(call (if_op (quote 0) (function_op (quote 100)) (function_op (quote 200))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/if-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(if 1 100 200)'
(call (if_op (quote 1) (function_op (quote 100)) (function_op (quote 200))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/if-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(if 0 x0 200)'
(call (if_op (quote 0) (function_op (quote x0)) (function_op (quote 200))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/if-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(if 0 100 x50)'
(call (if_op (quote 0) (function_op (quote 100)) (function_op (quote x50))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/if-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(if x0 100 200)'
(call (if_op (first (args)) (function_op (quote 100)) (function_op (quote 200))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/if-6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(if x38 100 200)'
(call (if_op (first (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (args)))))))))))))))))))))))))))))))))))))))) (function_op (quote 100)) (function_op (quote 200))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/int-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite 2
(quote 2)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/list-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(list 100 200 300 400 500)'
(cons (quote 100) (cons (quote 200) (cons (quote 300) (cons (quote 400) (cons (quote 500) (quote ()))))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/list-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(list 100 200 300 400 x0)'
(cons (quote 100) (cons (quote 200) (cons (quote 300) (cons (quote 400) (cons (first (args)) (quote ()))))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/list-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(list 100 200 (list 300 400 x0))'
(cons (quote 100) (cons (quote 200) (cons (cons (quote 300) (cons (quote 400) (cons (first (args)) (quote ())))) (quote ()))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/list-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(list x0 100 200 (list 300 400 500))'
(cons (first (args)) (cons (quote 100) (cons (quote 200) (cons (cons (quote 300) (cons (quote 400) (cons (quote 500) (quote ())))) (quote ())))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/map-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(map (quote (+ x0 1)) (list 100 200 300))'
(eval (function_op (quote (eval x0 (args)))) (cons (function_op (quote (if x2 (cons (eval x1 (list (first x2))) (eval x0 (list x0 x1 (rest x2)))) ()))) (cons (quote (+ x0 1)) (cons (cons (quote 100) (cons (quote 200) (cons (quote 300) (quote ())))) (quote ())))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/map-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(map x0 (list 100 200 300))'
(eval (function_op (quote (eval x0 (args)))) (cons (function_op (quote (if x2 (cons (eval x1 (list (first x2))) (eval x0 (list x0 x1 (rest x2)))) ()))) (cons (first (args)) (cons (cons (quote 100) (cons (quote 200) (cons (quote 300) (quote ())))) (quote ())))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/map-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(map (* x0 x0) (list 100 200 300))'
(eval (function_op (quote (eval x0 (args)))) (cons (function_op (quote (if x2 (cons (eval x1 (list (first x2))) (eval x0 (list x0 x1 (rest x2)))) ()))) (cons (* (first (args)) (first (args))) (cons (cons (quote 100) (cons (quote 200) (cons (quote 300) (quote ())))) (quote ())))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/not-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(not 0)'
(call (if_op (quote 0) (function_op (quote ())) (function_op (quote 1))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/not-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(not 1)'
(call (if_op (quote 1) (function_op (quote ())) (function_op (quote 1))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/not-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(not x0)'
(call (if_op (first (args)) (function_op (quote ())) (function_op (quote 1))) (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/not-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(not (not x0))'
(call (if_op (call (if_op (first (args)) (function_op (quote ())) (function_op (quote 1))) (args)) (function_op (quote ())) (function_op (quote 1))) (args))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(quasiquote 1)'
(quote 1)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(quasiquote x0)'
(quote x0)
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(quasiquote (unquote x0))'
(first (args))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(quasiquote (+ x0 (unquote x0)))'
(cons (quote +) (cons (function_op (quote x0)) (cons (first (args)) (quote ()))))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(quasiquote (unquote (+ 7 8 20)))'
(+ (quote 7) (quote 8) (quote 20))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(quasiquote (+ x0 (unquote (sha256 x0))))'
(cons (quote +) (cons (function_op (quote x0)) (cons (sha256 (first (args))) (quote ()))))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite '(quasiquote (100 200 300 400 500))'
(cons (quote 100) (cons (function_op (quote 200)) (cons (function_op (quote 300)) (cons (function_op (quote 400)) (cons (function_op (quote 500)) (quote ()))))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/var-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite x0
(first (args))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/attic/v0_0_2/rewrite/var-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
rewrite x59
(first (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (rest (args)))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/and-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod (A B) (include "macros.clvm") (and (= 1 1) (= 2 2) (= 3 3)))'
(q . 1)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/and-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod (A B) (include "macros.clvm") (and (= 1 1) (= 2 4) (= 3 3)))'
()
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/and-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod (A B) (include "macros.clvm") (and (= 1 2) (= 2 2) (= 3 3)))'
()
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/and-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod (A . B) (include "macros.clvm") (and (= 1 A) (= 2 B)))'
(a (i (= (q . 1) 2) (q 2 (i (= (q . 2) 3) (q 1 . 1) ()) 1) ()) 1)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/and-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(a (mod (A . B) (include "macros.clvm") (and (= 1 A) (= 2 B))) @)' "(1 . 2)"
1
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/and-6.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(a (mod (A . B) (include "macros.clvm") (and (= 1 A) (= 2 B))) @)' "(1 . 3)"
()
13 changes: 13 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/chia-constants.clvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
(
; these constants are for creating output conditions

(defconstant AGG_SIG 50)
(defconstant CREATE_COIN 51)
(defconstant ASSERT_COIN_CONSUMED 52)
(defconstant ASSERT_MY_COIN_ID 53)
(defconstant ASSERT_TIME_EXCEEDS 54)
(defconstant ASSERT_BLOCK_INDEX_EXCEEDS 55)
(defconstant ASSERT_BLOCK_AGE_EXCEEDS 56)
(defconstant AGG_SIG_ME 57)
(defconstant ASSERT_FEE 58)
)
56 changes: 56 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/curry.clvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
(
;; This include file defines various forms of `curry`
;; A "curry" binds values to a function, making them constant,
;; and returning a new function that returns fewer arguments (since the
;; arguments are now fixed).
;; Example: (defun add2 (V1 V2) (+ V1 V2)) ; add two values
;; (curry add2 15) ; this yields a function that accepts ONE argument, and adds 15 to it

; (curry_args sum (list 50 60)) => returns a function that is like (sum 50 60 ...)
(defun curry_args (func list_of_args) (qq (a (q . (unquote func)) (unquote (fix_curry_args list_of_args (q . 1))))))

;; (curry sum 50 60) => returns a function that is like (sum 50 60 ...)
(defun curry (func . args) (curry_args func args))

;; utility function used by `curry_args`
(defun fix_curry_args (items core)
(if items
(qq (c (q . (unquote (f items))) (unquote (fix_curry_args (r items) core))))
core
)
)

;; `curry_sha_args`: curry a function, passing in the hash of the original function,
;; and return (NEW_FUNCTION . SHA_TREE_OF_NEW_FUNCTION)
;; Since this function knows the hash of the original function, it doesn't need to recurse into that function;
;; it just uses the memoized hash.
;; If you're going to curry a function multiple times, using this function can save you
;; currying the core muliple times.

;; Example:
;;
;; Calculate the sha256tree of `add2`
;;
;; run -i clvm_runtime '(mod (X) (defun add2 (A B) (+ A B)) (include sha256tree.clvm) (sha256tree add2))'
;; (q . 0x4212e6549edf9ba3ce6bcd8839ecca37b430ec96ddbbae17e5c669d8e18bd17f)

;; Now calculate the sha256tree of `add2` when curried with `15`, ie. fixing A to 15
;;
;; run -i clvm_runtime '(mod (X) (defun add2 (A B) (+ A B)) (include curry.clvm) (include sha256tree.clvm) (sha256tree (curry add2 15)) )'
;; (q . 0xf90da10ec9e353929eb8ad3294986874e000fae0b62d5810e58ec6806b2a70ed)

;; Now, supposing we know the hash of `add2`, do it again but don't rehash `add2
;;
;; run -i clvm_runtime '(mod (X) (defun add2 (A B) (+ A B)) (include curry.clvm) (include sha256tree.clvm) (curry_sha add2 0x4212e6549edf9ba3ce6bcd8839ecca37b430ec96ddbbae17e5c669d8e18bd17f 15) )'
;; (q (a (q 16 5 11) (c (q . 15) 1)) . 0xf90da10ec9e353929eb8ad3294986874e000fae0b62d5810e58ec6806b2a70ed)

(defun curry_sha_args (func func_hash args)
(c (curry_args func args) (sha256tree_esc (curry_args func_hash args) func_hash))
)

;; return the hash of the curried function

(defun curry_sha (func func_hash . args)
(curry_sha_args func func_hash args)
)
)
23 changes: 23 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/macros.clvm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
(
;; boolean and macro
;; This lets you write something like (if (and COND1 COND2 COND3) (do-something) (do-something-else))
(defmacro and ARGS
(if ARGS
(qq (if (unquote (f ARGS))
(unquote (c and (r ARGS)))
()
))
1)
)

;; boolean or macro
;; This lets you write something like (if (or COND1 COND2 COND3) (do-something) (do-something-else))
(defmacro or ARGS
(if ARGS
(qq (if (unquote (f ARGS))
1
(unquote (c or (r ARGS)))
))
0)
)
)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/or-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod (A B) (include "macros.clvm") (or (= 1 0) (= 2 0) (= 3 3)))'
(q . 1)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/or-2.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime -i clvm_runtime '(mod (A B) (include "macros.clvm") (or (= 0 1) (= 2 4) (= 3 3)))'
(q . 1)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/or-3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod (A B) (include "macros.clvm") (or))'
()
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/or-4.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod (A . B) (include "macros.clvm") (or (= 1 A) (= 2 B)))'
(a (i (= (q . 1) 2) (q 1 . 1) (q 2 (i (= (q . 2) 3) (q 1 . 1) ()) 1)) 1)
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/or-5.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(a (mod (A . B) (include "macros.clvm") (or (= 1 A) (= 2 B))) @)' "(1 . 2)"
1
2 changes: 2 additions & 0 deletions resources/tests/cmdline/tests/clvm_runtime/sha256tree-1.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
run -i clvm_runtime '(mod X (include sha256tree.clvm) (sha256tree (quote (foo (bar baz 100 (383))))))'
(q . 0x6eeb86c37c74918fbaa0ba997bd938a63db7fbcc13e6680b1ea2ac8d6d1f7fb2)
Loading