Skip to content
This repository was archived by the owner on May 3, 2022. It is now read-only.

Commit 7afa695

Browse files
author
Kirill Taran
committed
Summator Solang test
1 parent f523925 commit 7afa695

10 files changed

Lines changed: 103 additions & 16 deletions

data/solidity/incrementer.sol

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
contract Incrementer {
2+
uint32 private value;
3+
4+
constructor(uint32 initvalue) public {
5+
value = initvalue;
6+
}
7+
8+
function inc(uint32 by) public {
9+
value += by;
10+
}
11+
12+
function get() public view returns (uint32) {
13+
return value;
14+
}
15+
}

data/solidity/summator.sol

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
contract Summator {
2+
uint32[10] private values;
3+
uint64 private sum;
4+
5+
constructor() public {
6+
uint8 i = 0;
7+
while (i < values.length) {
8+
values[i] = 0;
9+
i += 1;
10+
}
11+
sum = 0;
12+
}
13+
14+
function push(uint32 arg) public {
15+
sum -= values[9];
16+
17+
uint256 i = values.length - 2;
18+
while (i > 0) {
19+
values[i+1] = values[i];
20+
i -= 1;
21+
}
22+
values[1] = values[0];
23+
24+
values[0] = arg;
25+
sum += arg;
26+
}
27+
}

rust/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn main() {
6666
println!("Contract instantiated: {:?}", &address);
6767

6868
for method in args {
69-
//todo: so far, it is supposed to use only with 0-ary methods
69+
//todo: so far, it is supposed to be used only with 0-ary methods
7070
let result = call(&xt, &mut rt, 500_000, &code_hash, &method).unwrap();
7171
}
7272
}
@@ -124,4 +124,4 @@ fn extract_instance_address<T: System>(extrinsic_result: ExtrinsicSuccess<T>) ->
124124
"Failed to find Balances::NewAccount event"
125125
)),
126126
}
127-
}
127+
}

test/contracts/ink-flipper.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set -e
44
root=$(git rev-parse --show-toplevel)
55
data=$root/data
66

7-
cd $root/typescript
8-
97
rpc_contracts="$1contracts$2 -q"
108

119
$rpc_contracts deploy -f $data/ink/flipper.wasm -g 123456

test/contracts/solang-flipper-initvalue.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ set -e
44
root=$(git rev-parse --show-toplevel)
55
data=$root/data
66

7-
cd $root/typescript
8-
97
rpc_contracts="$1contracts$2 -q" # remove "-q" to see verbose output
108

11-
selector=123 #contracts_bug: Substrate accepts any number
9+
selector=123 #solang_bug: accepts any selector
1210

1311
$rpc_contracts deploy -f $data/solidity/wasm/Flipper_with_initvalue.wasm -g 12345
1412
$rpc_contracts instantiate -h 0xb0af3c55f42bcb4aaf561844818531b6b71ddfaf01a6f1506c520dc05df66e0e -e 1234567DEV -g 1234567 -d 0x"$selector"00

test/contracts/solang-flipper-noargs.sh

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,14 @@ set -e
44
root=$(git rev-parse --show-toplevel)
55
data=$root/data
66

7-
cd $root/typescript
8-
97
rpc_contracts="$1contracts$2 -q" # remove "-q" to see verbose output
108

11-
selector=123 #contracts_bug: Substrate accepts any number
9+
selector=123 #solang_bug: accepts any selector
1210

1311
$rpc_contracts deploy -f $data/solidity/wasm/Flipper_no_args.wasm -g 12345
14-
$rpc_contracts instantiate -h 0xb0af3c55f42bcb4aaf561844818531b6b71ddfaf01a6f1506c520dc05df66e0e -e 1234567DEV -g 1234567 -d 0x"$selector"
12+
$rpc_contracts instantiate -h 0x9498960359c5cb825ccc10d4c7ae50bfd4264a6a115a9390ddaebd276635d05a -e 1234567DEV -g 1234567 -d 0x"$selector"
1513

16-
address=5EVKDR8WZNXQv5oPqnESUhknFUkHU8uAgrXkqXySNcbtCeL2
14+
address=5GMgqHXTSBVxgd7LWKm8zCzCedi1X6w5AWoZfMcmpEQzZ9g2
1715

1816
$rpc_contracts info -a $address
1917
$rpc_contracts call -a $address -e 123DEV -d 0xa9efe4cd -g 1234567
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
set -e
4+
root=$(git rev-parse --show-toplevel)
5+
data=$root/data
6+
7+
rpc_contracts="$1contracts$2 -q" # remove "-q" to see verbose output
8+
9+
selector=123 #solang_bug: accepts any selector
10+
11+
$rpc_contracts deploy -f $data/solidity/wasm/Incrementer.wasm -g 12345
12+
$rpc_contracts instantiate -h 0xf030ffd7093148f34bf5ac3092dec596bc57e20e2c925d8865b20e83c2c91a06 -e 1234567DEV -g 1234567 -d 0x"$selector"00
13+
14+
address=5GySUBy91ZpK7WV1JYgvz96Dk7M7M6es3Nt9RYPWBsgtsQh9
15+
16+
$rpc_contracts info -a $address
17+
exit 1
18+
$rpc_contracts call -a $address -e 123DEV -d 0xa9efe4cd -g 1234567
19+
$rpc_contracts info -a $address
20+
$rpc_contracts call -a $address -e 123DEV -d 0xa9efe4cd -g 1234567
21+
$rpc_contracts info -a $address

test/contracts/solang-summator.sh

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -e
4+
root=$(git rev-parse --show-toplevel)
5+
data=$root/data
6+
7+
rpc_contracts="$1contracts$2 -q" # remove "-q" to see verbose output
8+
9+
selector=123 #solang_bug: accepts any selector
10+
#selector="d5311786"
11+
12+
$rpc_contracts deploy -f $data/solidity/wasm/Summator.wasm -g 12345
13+
$rpc_contracts instantiate -h 0x49803e4720f9fd6edb897920575424a555365b19b757639f8b5c7754290f0573 -e 1234567DEV -g 1234567 -d 0x"$selector"
14+
15+
address=5CMgTCRgBaUTMuqCJi9PkDCCnM1WkRku7U9HNv1CBhAtHuH9
16+
selector="40e4f0f7"
17+
18+
$rpc_contracts info -a $address
19+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"01 -g 1234567
20+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"02 -g 1234567
21+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"03 -g 1234567
22+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"04 -g 1234567
23+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"05 -g 1234567
24+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"06 -g 1234567
25+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"07 -g 1234567
26+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"08 -g 1234567
27+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"09 -g 1234567
28+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"10 -g 1234567
29+
$rpc_contracts info -a $address
30+
echo "The result must be 0x37 (1+2+3+4+5+6+7+8+9+10=55)"
31+
32+
$rpc_contracts call -a $address -e 123DEV -d 0x"$selector"11 -g 1234567
33+
$rpc_contracts info -a $address
34+
echo "The result must be 0x41 (2+3+4+5+6+7+8+9+10+11=65)"

test/contracts/waterfall-flipper.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set -e
44
root=$(git rev-parse --show-toplevel)
55
data=$root/data
66

7-
cd $root/typescript
8-
97
rpc_contracts="$1contracts$2 -q"
108

119
initvalue=0x1337 #contracts_bug: Substrate accepts any value here

test/contracts/waterfall-incrementer.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ set -e
44
root=$(git rev-parse --show-toplevel)
55
data=$root/data
66

7-
cd $root/typescript
8-
97
rpc_contracts="$1contracts$2 -q"
108

119
$rpc_contracts deploy -f $data/waterfall/asmscript/incrementer.wasm -g 10000

0 commit comments

Comments
 (0)