mirror of https://github.com/nucypher/nucypher.git
Add basic test for custom abi condition
parent
49a3ec2bf9
commit
4ce6f72695
|
@ -1,4 +1,46 @@
|
|||
{
|
||||
"TStaking": {
|
||||
"contractAddress": "0x01B67b1194C75264d06F808A921228a95C765dd7",
|
||||
"chain": "ethereum",
|
||||
"method": "stakes",
|
||||
"functionAbi": {
|
||||
"inputs": [
|
||||
{
|
||||
"internalType": "address",
|
||||
"name": "stakingProvider",
|
||||
"type": "address"
|
||||
}
|
||||
],
|
||||
"name": "stakes",
|
||||
"outputs": [
|
||||
{
|
||||
"internalType": "uint96",
|
||||
"name": "tStake",
|
||||
"type": "uint96"
|
||||
},
|
||||
{
|
||||
"internalType": "uint96",
|
||||
"name": "keepInTStake",
|
||||
"type": "uint96"
|
||||
},
|
||||
{
|
||||
"internalType": "uint96",
|
||||
"name": "nuInTStake",
|
||||
"type": "uint96"
|
||||
}
|
||||
],
|
||||
"stateMutability": "view",
|
||||
"type": "function"
|
||||
},
|
||||
"parameters": [
|
||||
":userAddress"
|
||||
],
|
||||
"returnValueTest": {
|
||||
"key": "tStake",
|
||||
"comparator": ">",
|
||||
"value": 0
|
||||
}
|
||||
},
|
||||
"SubscriptionManagerPayment": {
|
||||
"contractAddress": "0xaDD9D957170dF6F33982001E4c22eCCdd5539118",
|
||||
"chain": 137,
|
||||
|
|
|
@ -41,6 +41,11 @@ def mock_condition_blockchains(mocker):
|
|||
mocker.patch.object(nucypher.policy.conditions.evm, '_CONDITION_CHAINS', tuple([131277322940537]))
|
||||
|
||||
|
||||
@pytest.fixture()
|
||||
def TStaking_data():
|
||||
return json.dumps(VECTORS["TStaking"])
|
||||
|
||||
|
||||
# ERC1155
|
||||
|
||||
@pytest.fixture()
|
||||
|
|
|
@ -22,12 +22,20 @@ from nucypher.policy.conditions.evm import ContractCondition
|
|||
from nucypher.policy.conditions.lingo import ConditionLingo
|
||||
|
||||
|
||||
def test_evm_condition_function_abi(TStaking_data):
|
||||
original_data = TStaking_data
|
||||
condition = ContractCondition.from_json(original_data)
|
||||
serialized_data = condition.to_json()
|
||||
|
||||
deserialized_data = json.loads(serialized_data)
|
||||
assert deserialized_data["functionAbi"] == condition.function_abi
|
||||
|
||||
|
||||
def test_evm_condition_json_serializers(ERC1155_balance_condition_data):
|
||||
original_data = ERC1155_balance_condition_data
|
||||
condition = ContractCondition.from_json(original_data)
|
||||
serialized_data = condition.to_json()
|
||||
|
||||
# TODO functionAbi is present in serialized data
|
||||
deserialized_data = json.loads(serialized_data)
|
||||
deserialized_data.pop("functionAbi")
|
||||
|
||||
|
|
Loading…
Reference in New Issue