Skip to content

Commit

Permalink
Update rbac abi and rbac tests with proper types
Browse files Browse the repository at this point in the history
  • Loading branch information
talhadaar committed Oct 27, 2023
1 parent 326212a commit b3ce15c
Show file tree
Hide file tree
Showing 2 changed files with 110 additions and 6 deletions.
108 changes: 105 additions & 3 deletions ETH/rbac/rbac.sol.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@
{
"indexed": false,
"internalType": "address",
"name": "owner",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "owner",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes32",
Expand All @@ -24,6 +30,37 @@
"name": "RoleAdded",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "owner",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes32",
"name": "role_id",
"type": "bytes32"
},
{
"indexed": false,
"internalType": "bytes",
"name": "name",
"type": "bytes"
}
],
"name": "RoleUpdated",
"type": "event"
},
{
"inputs": [
{
Expand Down Expand Up @@ -51,9 +88,9 @@
{
"inputs": [
{
"internalType": "address",
"internalType": "bytes32",
"name": "owner",
"type": "address"
"type": "bytes32"
},
{
"internalType": "bytes32",
Expand Down Expand Up @@ -88,5 +125,70 @@
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "owner",
"type": "bytes32"
},
{
"internalType": "bytes32",
"name": "role",
"type": "bytes32"
}
],
"name": "fetch_roles",
"outputs": [
{
"components": [
{
"internalType": "bytes32",
"name": "owner",
"type": "bytes32"
},
{
"internalType": "bytes",
"name": "name",
"type": "bytes"
},
{
"internalType": "bool",
"name": "enabled",
"type": "bool"
}
],
"internalType": "struct RBAC.EntityAttribute[]",
"name": "",
"type": "tuple[]"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "bytes32",
"name": "role_id",
"type": "bytes32"
},
{
"internalType": "bytes",
"name": "name",
"type": "bytes"
}
],
"name": "update_role",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
8 changes: 5 additions & 3 deletions tests/bridge_rbac_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
TOKEN_NUM = 10000 * pow(10, 15)

# A role and it's name
ROLE_ID_1 = generate_random_hex()
ROLE_ID_1_NAME = 'role1'
ROLE_ID_1 = generate_random_hex(15).encode("utf-8")
ROLE_ID_1_NAME = generate_random_hex(15).encode("utf-8")


def _calcualte_evm_basic_req(substrate, w3, addr):
Expand Down Expand Up @@ -78,6 +78,8 @@ def check_item_from_event(self, event, account, role_id, name):
self.assertEqual(f"0x{events[0]['args']['name'].hex()}", f"{name}")

def test_add_role_and_check(self):
print("ROLE_ID ", ROLE_ID_1, "len: ", len(ROLE_ID_1))

substrate = self._substrate
eth_src = self._eth_src
w3 = self._w3
Expand Down Expand Up @@ -106,4 +108,4 @@ def test_add_role_and_check(self):
data = contract.functions.fetch_role(account, ROLE_ID_1).call()

# Check: Fetch Role
self.assertEqual(f'0x{data.hex()}', ROLE_ID_1_NAME)
self.assertEqual(f'0x{data.hex()}', ROLE_ID_1_NAME)

0 comments on commit b3ce15c

Please sign in to comment.