Skip to content

Commit 58a1945

Browse files
committed
forc node forking integration test contracts
1 parent 1e080f6 commit 58a1945

File tree

12 files changed

+278
-0
lines changed

12 files changed

+278
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[[package]]
2+
name = "fork-caller"
3+
source = "member"
4+
dependencies = ["std"]
5+
6+
[[package]]
7+
name = "std"
8+
version = "0.69.1"
9+
source = "registry+std?0.69.1#QmbPunScay4xpfHKpxQ71dFKXSiyJuPP8P8YhgX5Dkmzm9!"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[project]
2+
authors = ["z"]
3+
entry = "main.sw"
4+
license = "Apache-2.0"
5+
name = "fork-caller"
6+
7+
[dependencies]
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
{
2+
"programType": "contract",
3+
"specVersion": "1.1",
4+
"encodingVersion": "1",
5+
"concreteTypes": [
6+
{
7+
"type": "struct Adder",
8+
"concreteTypeId": "4717fd7abcab99b1028d795354df7d1cddda94883a45770a6d7c8cae0c21173f",
9+
"metadataTypeId": 2
10+
},
11+
{
12+
"type": "struct std::contract_id::ContractId",
13+
"concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54",
14+
"metadataTypeId": 3
15+
},
16+
{
17+
"type": "u64",
18+
"concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
19+
}
20+
],
21+
"metadataTypes": [
22+
{
23+
"type": "(_, _)",
24+
"metadataTypeId": 0,
25+
"components": [
26+
{
27+
"name": "__tuple_element",
28+
"typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
29+
},
30+
{
31+
"name": "__tuple_element",
32+
"typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
33+
}
34+
]
35+
},
36+
{
37+
"type": "b256",
38+
"metadataTypeId": 1
39+
},
40+
{
41+
"type": "struct Adder",
42+
"metadataTypeId": 2,
43+
"components": [
44+
{
45+
"name": "_vals",
46+
"typeId": 0
47+
}
48+
]
49+
},
50+
{
51+
"type": "struct std::contract_id::ContractId",
52+
"metadataTypeId": 3,
53+
"components": [
54+
{
55+
"name": "bits",
56+
"typeId": 1
57+
}
58+
]
59+
}
60+
],
61+
"functions": [
62+
{
63+
"name": "call_increment_count",
64+
"inputs": [
65+
{
66+
"name": "contract_id",
67+
"concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54"
68+
},
69+
{
70+
"name": "adder",
71+
"concreteTypeId": "4717fd7abcab99b1028d795354df7d1cddda94883a45770a6d7c8cae0c21173f"
72+
}
73+
],
74+
"output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0",
75+
"attributes": null
76+
},
77+
{
78+
"name": "check_current_count",
79+
"inputs": [
80+
{
81+
"name": "contract_id",
82+
"concreteTypeId": "29c10735d33b5159f0c71ee1dbd17b36a3e69e41f00fab0d42e1bd9f428d8a54"
83+
}
84+
],
85+
"output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0",
86+
"attributes": null
87+
}
88+
],
89+
"loggedTypes": [],
90+
"messagesTypes": [],
91+
"configurables": [],
92+
"errorCodes": {}
93+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[]
3.3 KB
Binary file not shown.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
contract;
2+
3+
struct Adder {
4+
_vals: (u64, u64),
5+
}
6+
7+
abi Fork {
8+
#[storage(read)]
9+
fn get_count() -> u64;
10+
11+
#[storage(read, write)]
12+
fn increment_count(adder: Adder);
13+
}
14+
15+
abi ForkCaller {
16+
fn call_increment_count(contract_id: ContractId, adder: Adder) -> u64;
17+
fn check_current_count(contract_id: ContractId) -> u64;
18+
}
19+
20+
impl ForkCaller for Contract {
21+
fn check_current_count(contract_id: ContractId) -> u64 {
22+
let fork = abi(Fork, contract_id.bits());
23+
fork.get_count()
24+
}
25+
26+
fn call_increment_count(contract_id: ContractId, adder: Adder) -> u64 {
27+
let fork = abi(Fork, contract_id.bits());
28+
fork.increment_count(adder);
29+
fork.get_count()
30+
}
31+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[[package]]
2+
name = "fork"
3+
source = "member"
4+
dependencies = ["std"]
5+
6+
[[package]]
7+
name = "std"
8+
version = "0.69.1"
9+
source = "registry+std?0.69.1#QmbPunScay4xpfHKpxQ71dFKXSiyJuPP8P8YhgX5Dkmzm9!"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[project]
2+
authors = ["z"]
3+
entry = "main.sw"
4+
license = "Apache-2.0"
5+
name = "fork"
6+
7+
[dependencies]
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
"programType": "contract",
3+
"specVersion": "1.1",
4+
"encodingVersion": "1",
5+
"concreteTypes": [
6+
{
7+
"type": "()",
8+
"concreteTypeId": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d"
9+
},
10+
{
11+
"type": "struct Adder",
12+
"concreteTypeId": "4717fd7abcab99b1028d795354df7d1cddda94883a45770a6d7c8cae0c21173f",
13+
"metadataTypeId": 1
14+
},
15+
{
16+
"type": "u64",
17+
"concreteTypeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
18+
}
19+
],
20+
"metadataTypes": [
21+
{
22+
"type": "(_, _)",
23+
"metadataTypeId": 0,
24+
"components": [
25+
{
26+
"name": "__tuple_element",
27+
"typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
28+
},
29+
{
30+
"name": "__tuple_element",
31+
"typeId": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0"
32+
}
33+
]
34+
},
35+
{
36+
"type": "struct Adder",
37+
"metadataTypeId": 1,
38+
"components": [
39+
{
40+
"name": "vals",
41+
"typeId": 0
42+
}
43+
]
44+
}
45+
],
46+
"functions": [
47+
{
48+
"name": "get_count",
49+
"inputs": [],
50+
"output": "1506e6f44c1d6291cdf46395a8e573276a4fa79e8ace3fc891e092ef32d1b0a0",
51+
"attributes": [
52+
{
53+
"name": "storage",
54+
"arguments": [
55+
"read"
56+
]
57+
}
58+
]
59+
},
60+
{
61+
"name": "increment_count",
62+
"inputs": [
63+
{
64+
"name": "adder",
65+
"concreteTypeId": "4717fd7abcab99b1028d795354df7d1cddda94883a45770a6d7c8cae0c21173f"
66+
}
67+
],
68+
"output": "2e38e77b22c314a449e91fafed92a43826ac6aa403ae6a8acb6cf58239fbaf5d",
69+
"attributes": [
70+
{
71+
"name": "storage",
72+
"arguments": [
73+
"read",
74+
"write"
75+
]
76+
}
77+
]
78+
}
79+
],
80+
"loggedTypes": [],
81+
"messagesTypes": [],
82+
"configurables": [],
83+
"errorCodes": {}
84+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[
2+
{
3+
"key": "cbf93a9497b1d9a9fa1e5a4c96595c511ddd6d9aef9c1e485177a4834998f371",
4+
"value": "0000000000000000000000000000000000000000000000000000000000000000"
5+
}
6+
]

0 commit comments

Comments
 (0)