Skip to content

Commit

Permalink
Merge pull request #423 from alephium/fix-nested-map-call-tests
Browse files Browse the repository at this point in the history
Fix the unit tests for the nested map call
  • Loading branch information
polarker authored Sep 11, 2024
2 parents f151f60 + f361eb1 commit c3dca20
Show file tree
Hide file tree
Showing 35 changed files with 732 additions and 109 deletions.
16 changes: 11 additions & 5 deletions .project.json
Original file line number Diff line number Diff line change
Expand Up @@ -180,19 +180,25 @@
},
"InsertIntoMap": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f797013ab9c7bf780bb8f452c0724703e877bbd9d71a60b400ed5009eb0f08e8",
"sourceCodeHash": "331b92fe6617c1c7ac7f742ceea1943a06717477a2bd03ca266d23c65d844de6",
"bytecodeDebugPatch": "",
"codeHashDebug": ""
},
"MapTest": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f797013ab9c7bf780bb8f452c0724703e877bbd9d71a60b400ed5009eb0f08e8",
"sourceCodeHash": "331b92fe6617c1c7ac7f742ceea1943a06717477a2bd03ca266d23c65d844de6",
"bytecodeDebugPatch": "=6-2+a8=1-3+128=2-2+ea=1+2=1-2+7=10-2+4025=50+7a7e0214696e73657274206174206d617020706174683a2000=56+7a7e0214696e73657274206174206d617020706174683a2000=54+7a7e0214696e73657274206174206d617020706174683a2000=280-2+33=124+7a7e021472656d6f7665206174206d617020706174683a2000=46+7a7e021472656d6f7665206174206d617020706174683a2000=48+7a7e021472656d6f7665206174206d617020706174683a2000=96",
"codeHashDebug": "31aed0ff7b29f2cbc2d8360a83f31af4e9db00f0084a7406bd84b7745181373d"
},
"MapTestWrapper": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "331b92fe6617c1c7ac7f742ceea1943a06717477a2bd03ca266d23c65d844de6",
"bytecodeDebugPatch": "",
"codeHashDebug": "1d525d3e4cbd1c8f4c0431bf6881e888eeebae012a14532530097f62dd766e9a"
},
"MapValue": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f797013ab9c7bf780bb8f452c0724703e877bbd9d71a60b400ed5009eb0f08e8",
"sourceCodeHash": "331b92fe6617c1c7ac7f742ceea1943a06717477a2bd03ca266d23c65d844de6",
"bytecodeDebugPatch": "",
"codeHashDebug": ""
},
Expand Down Expand Up @@ -258,7 +264,7 @@
},
"RemoveFromMap": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f797013ab9c7bf780bb8f452c0724703e877bbd9d71a60b400ed5009eb0f08e8",
"sourceCodeHash": "331b92fe6617c1c7ac7f742ceea1943a06717477a2bd03ca266d23c65d844de6",
"bytecodeDebugPatch": "",
"codeHashDebug": ""
},
Expand Down Expand Up @@ -306,7 +312,7 @@
},
"UpdateMapValue": {
"sourceFile": "test/map.ral",
"sourceCodeHash": "f797013ab9c7bf780bb8f452c0724703e877bbd9d71a60b400ed5009eb0f08e8",
"sourceCodeHash": "331b92fe6617c1c7ac7f742ceea1943a06717477a2bd03ca266d23c65d844de6",
"bytecodeDebugPatch": "",
"codeHashDebug": ""
},
Expand Down
64 changes: 64 additions & 0 deletions artifacts/test/MapTestWrapper.ral.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"version": "v3.6.2",
"name": "MapTestWrapper",
"bytecode": "01031d4030404301030303000dd3a9cdcc691600d10f2ca21600160116020f0cce000100010001010006d3c50ed2bb16000d0cce000101010001010006d392ac086616000d0cce000102",
"codeHash": "1d525d3e4cbd1c8f4c0431bf6881e888eeebae012a14532530097f62dd766e9a",
"fieldsSig": {
"names": [
"inner"
],
"types": [
"MapTest"
],
"isMutable": [
false
]
},
"eventsSig": [],
"functions": [
{
"name": "insert",
"paramNames": [
"key",
"value"
],
"paramTypes": [
"Address",
"MapValue"
],
"paramIsMutable": [
false,
false
],
"returnTypes": []
},
{
"name": "update",
"paramNames": [
"key"
],
"paramTypes": [
"Address"
],
"paramIsMutable": [
false
],
"returnTypes": []
},
{
"name": "remove",
"paramNames": [
"key"
],
"paramTypes": [
"Address"
],
"paramIsMutable": [
false
],
"returnTypes": []
}
],
"constants": [],
"enums": []
}
5 changes: 5 additions & 0 deletions artifacts/ts/Add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -239,6 +240,10 @@ class Factory extends ContractFactory<AddInstance, AddTypes.Fields> {
return testMethod(this, "destroy", params, getContractByCodeHash);
},
};

stateForTest(initFields: AddTypes.Fields, asset?: Asset, address?: string) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
5 changes: 5 additions & 0 deletions artifacts/ts/Assert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -104,6 +105,10 @@ class Factory extends ContractFactory<AssertInstance, {}> {
);
},
};

stateForTest(initFields: {}, asset?: Asset, address?: string) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
5 changes: 5 additions & 0 deletions artifacts/ts/Debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -104,6 +105,10 @@ class Factory extends ContractFactory<DebugInstance, {}> {
);
},
};

stateForTest(initFields: {}, asset?: Asset, address?: string) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/DeprecatedNFTTest1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -111,6 +112,14 @@ class Factory extends ContractFactory<
return testMethod(this, "getTokenUri", params, getContractByCodeHash);
},
};

stateForTest(
initFields: DeprecatedNFTTest1Types.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/DeprecatedNFTTest2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -127,6 +128,14 @@ class Factory extends ContractFactory<
return testMethod(this, "getCollectionId", params, getContractByCodeHash);
},
};

stateForTest(
initFields: DeprecatedNFTTest2Types.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/DeprecatedNFTTest3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -127,6 +128,14 @@ class Factory extends ContractFactory<
return testMethod(this, "returnNothing", params, getContractByCodeHash);
},
};

stateForTest(
initFields: DeprecatedNFTTest3Types.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/DeprecatedNFTTest4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -127,6 +128,14 @@ class Factory extends ContractFactory<
return testMethod(this, "getBool", params, getContractByCodeHash);
},
};

stateForTest(
initFields: DeprecatedNFTTest4Types.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/DeprecatedNFTTest5.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -132,6 +133,14 @@ class Factory extends ContractFactory<
);
},
};

stateForTest(
initFields: DeprecatedNFTTest5Types.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/DeprecatedNFTTest6.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -127,6 +128,14 @@ class Factory extends ContractFactory<
return testMethod(this, "getArray", params, getContractByCodeHash);
},
};

stateForTest(
initFields: DeprecatedNFTTest6Types.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/DeprecatedNFTTest7.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -132,6 +133,14 @@ class Factory extends ContractFactory<
);
},
};

stateForTest(
initFields: DeprecatedNFTTest7Types.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/FakeTokenTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -174,6 +175,14 @@ class Factory extends ContractFactory<
return testMethod(this, "foo", params, getContractByCodeHash);
},
};

stateForTest(
initFields: FakeTokenTestTypes.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
9 changes: 9 additions & 0 deletions artifacts/ts/Greeter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
callMethod,
multicallMethods,
fetchContractState,
Asset,
ContractInstance,
getContractEventsCurrentCount,
TestContractParamsWithoutMaps,
Expand Down Expand Up @@ -115,6 +116,14 @@ class Factory extends ContractFactory<GreeterInstance, GreeterTypes.Fields> {
return testMethod(this, "greet", params, getContractByCodeHash);
},
};

stateForTest(
initFields: GreeterTypes.Fields,
asset?: Asset,
address?: string
) {
return this.stateForTest_(initFields, asset, address, undefined);
}
}

// Use this object to test and deploy the contract
Expand Down
Loading

0 comments on commit c3dca20

Please sign in to comment.