Skip to content

Commit

Permalink
Coindrip test (#178)
Browse files Browse the repository at this point in the history
* Coindrip test

* Set Version: 0.1.11

* add more logging

* fix the `amount is zero` error

* refactor `get_balance`

* avoid cloning big ints

* save and reuse `last_stream_id`

* Set Version: 0.1.12

* Set Version: 0.1.13

---------

Co-authored-by: devops <[email protected]>
Co-authored-by: Burak Bilge Yalcinkaya <[email protected]>
  • Loading branch information
3 people authored Mar 12, 2024
1 parent d221389 commit 43e7bb2
Show file tree
Hide file tree
Showing 21 changed files with 5,308 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ tmp
.krun*
.kprove*
.kompile*
kdist

*.pyc
venv
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
[submodule "deps/mx-exchange-sc"]
path = deps/mx-exchange-sc
url = https://github.com/multiversx/mx-exchange-sc
[submodule "deps/coindrip-protocol-sc"]
path = deps/coindrip-protocol-sc
url = https://github.com/CoinDrip-finance/coindrip-protocol-sc
1 change: 1 addition & 0 deletions deps/coindrip-protocol-sc
Submodule coindrip-protocol-sc added at 3934e6
11 changes: 8 additions & 3 deletions generate-claims.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ K_OPTS="-Xmx8192m" kbuild kompile llvm-kasmer && poetry -C kmultiversx run -- ka

# Coindrip

# mxpy contract build --path deps/coindrip-protocol-sc --wasm-symbols --no-wasm-opt
# mxpy contract build --path tests/contracts/test_coindrip --wasm-symbols --no-wasm-opt
# K_OPTS="-Xmx8192m" kbuild kompile llvm-kasmer && poetry -C kmultiversx run -- kasmer --definition-dir $(kbuild which llvm-kasmer) --directory "tests/contracts/test_coindrip" --gen-claims 2>&1 | tee kasmer.log
for f in $(find deps/coindrip-protocol-sc/ -name 'Cargo.toml')
do
cat $f | sed 's/0.39.2/0.47.4/' > tmp.rs
mv tmp.rs $f
done
sc-meta all build --path deps/coindrip-protocol-sc --wasm-symbols --no-wasm-opt
sc-meta all build --path tests/contracts/test_coindrip --wasm-symbols --no-wasm-opt
K_OPTS="-Xmx8192m" kbuild kompile llvm-kasmer && poetry -C kmultiversx run -- kasmer --definition-dir $(kbuild which llvm-kasmer) --directory "tests/contracts/test_coindrip" --gen-claims 2>&1 | tee kasmer.log

# Crowdfunding

Expand Down
14 changes: 14 additions & 0 deletions kasmer.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,11 @@ Only the `#foundryRunner` account can execute these commands/host functions.
</esdtData>
...
</account>
<logging> S
=> S +String " -- setESDTBalance "
+String Bytes2String(ADDR) +String " "
+String Bytes2String(TOK_ID)
</logging>
requires 0 <=Int VALUE
// add new ESDT data
Expand All @@ -336,6 +341,11 @@ Only the `#foundryRunner` account can execute these commands/host functions.
</esdtData>)
...
</account>
<logging> S
=> S +String " -- setESDTBalance "
+String Bytes2String(ADDR) +String " "
+String Bytes2String(TOK_ID)
</logging>
requires 0 <=Int VALUE
[priority(60)]
Expand Down Expand Up @@ -496,6 +506,10 @@ Only the `#foundryRunner` account can execute these commands/host functions.
0 |-> <i64> TIMESTAMP
</locals>
<curBlockTimestamp> _ => TIMESTAMP </curBlockTimestamp>
<logging> S
=> S +String " -- setBlockTimestamp "
+String Int2String(TIMESTAMP)
</logging>
<callee> #foundryRunner </callee>
```
Expand Down
2 changes: 1 addition & 1 deletion kmultiversx/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "kmultiversx"
version = "0.1.12"
version = "0.1.13"
description = "Python tools for Elrond semantics"
authors = [
"Runtime Verification, Inc. <[email protected]>",
Expand Down
6 changes: 6 additions & 0 deletions kmultiversx/src/kmultiversx/kasmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ def type_to_strategy(typ: str) -> SearchStrategy[str]:
return integers(min_value=0).map(str)
if typ == 'u32':
return integers(min_value=0, max_value=4294967295).map(str)
if typ == 'u64':
return integers(min_value=0, max_value=18446744073709551615).map(str)
raise TypeError(f'Cannot create random {typ}')


Expand Down Expand Up @@ -446,6 +448,8 @@ def type_to_sort(typ: str) -> KSort:
return KSort('Int')
if typ == 'u32':
return KSort('Int')
if typ == 'u64':
return KSort('Int')
raise TypeError(f'Unsupported type {typ}')


Expand All @@ -454,6 +458,8 @@ def type_to_constraint(typ: str, var: KVariable) -> tuple[KInner, ...]:
return (leInt(KInt(0), var),)
if typ == 'u32':
return (leInt(KInt(0), var), leInt(var, KInt(4294967295)))
if typ == 'u64':
return (leInt(KInt(0), var), leInt(var, KInt(18446744073709551615)))
raise TypeError(f'Unsupported type {typ}')


Expand Down
2 changes: 1 addition & 1 deletion package/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.12
0.1.13
7 changes: 7 additions & 0 deletions tests/contracts/test_coindrip/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generated by Cargo
# will have compiled files and executables
/target/
*/target/

# The mxpy output
/output*/
Loading

0 comments on commit 43e7bb2

Please sign in to comment.