@@ -26,18 +26,21 @@ npm i solidity-patricia-tree
26
26
```
27
27
28
28
``` solidity
29
+
29
30
pragma solidity ^0.4.25;
30
31
31
32
import {PatriciaTree} from "solidity-patricia-tree/contracts/tree.sol";
32
- contract YourContract {
33
+
34
+ contract TestPatriciaTree {
33
35
using PatriciaTree for PatriciaTree.Tree;
36
+ PatriciaTree.Tree tree;
34
37
35
- function test() {
36
- //testInsert();
38
+ function test() public {
39
+ // testInsert();
37
40
testProofs();
38
41
}
42
+
39
43
function testInsert() internal {
40
- PatriciaTree.Tree memory tree;
41
44
tree.insert("one", "ONE");
42
45
tree.insert("two", "ONE");
43
46
tree.insert("three", "ONE");
@@ -48,18 +51,18 @@ contract YourContract {
48
51
// update
49
52
tree.insert("one", "TWO");
50
53
}
54
+
51
55
function testProofs() internal {
52
- PatriciaTree.Tree memory tree;
53
56
tree.insert("one", "ONE");
54
57
uint branchMask;
55
- bytes32[] siblings;
58
+ bytes32[] memory siblings;
56
59
(branchMask, siblings) = tree.getProof("one");
57
- tree .verifyProof(root, "one", "ONE", branchMask, siblings);
60
+ PatriciaTree .verifyProof(tree. root, "one", "ONE", branchMask, siblings);
58
61
tree.insert("two", "TWO");
59
62
(branchMask, siblings) = tree.getProof("one");
60
- tree .verifyProof(root, "one", "ONE", branchMask, siblings);
63
+ PatriciaTree .verifyProof(tree. root, "one", "ONE", branchMask, siblings);
61
64
(branchMask, siblings) = tree.getProof("two");
62
- tree .verifyProof(root, "two", "TWO", branchMask, siblings);
65
+ PatriciaTree .verifyProof(tree. root, "two", "TWO", branchMask, siblings);
63
66
}
64
67
}
65
68
```
0 commit comments