Skip to content

Commit

Permalink
fixup: resolution tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanchriswhite committed Dec 22, 2022
1 parent 87544b6 commit 9f1d4b5
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions tests/e2e/entities/test_almanac.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def test_resolutions_gql(self):
resolutions = gql_result["almanacResolutions"]["nodes"]
self.assertEqual(len(expected_resolutions), len(resolutions))

# TODO: use respective gql order by when available
# NB: sort by expiry height so that indexes match
# their respective expected_resolutions index
list.sort(resolutions, key=gql_by_endpoint_port)
Expand All @@ -208,7 +207,6 @@ def test_resolutions_gql(self):
)
self.assertRegex(record["transactionId"], tx_id_regex)
self.assertRegex(record["blockId"], block_id_regex)
# TODO: assert record equality

def test_registrations_sql(self):
registrations = self.db_cursor.execute(
Expand Down Expand Up @@ -340,7 +338,6 @@ def test_registrations_gql(self):
registrations = gql_result["almanacRegistrations"]["nodes"]
self.assertEqual(len(scenario.expected), len(registrations))

# TODO: use respective gql order by when available
# NB: sort by expiry height so that indexes match
# their respective scenario.expected index
list.sort(registrations, key=gql_by_expiry_height)
Expand All @@ -360,7 +357,51 @@ def test_registrations_gql(self):
)
self.assertRegex(registration["transactionId"], tx_id_regex)
self.assertRegex(registration["blockId"], block_id_regex)
# TODO: assert record equality

record = registration["record"]
self.assertEqual(
record["service"],
registration["record"]["service"],
)
self.assertRegex(record["transactionId"], tx_id_regex)
self.assertRegex(record["blockId"], block_id_regex)

def test_contract_interface_sql(self):
contract = self.db_cursor.execute(
"""SELECT c.id
FROM app.contracts c
WHERE c.interface = 'MicroAgentAlmanac'"""
).fetchone()
self.assertIsNotNone(contract)
self.assertEqual(str(self._contract.address), contract[0])

def test_contract_interface_gql(self):
expected_interface = "MicroAgentAlmanac"
results = self.gql_client.execute(
gql(
"""
query {
contracts (filter: {interface: {equalTo: """
+ expected_interface
+ """}}) {
nodes {
id
interface
storeMessageId
instantiateMessageId
}
}
}
"""
)
)

contract = results["contracts"]["nodes"][0]
self.assertIsNotNone(contract)
self.assertEqual(str(self._contract.address), contract["id"])
self.assertEqual(expected_interface, contract["interface"])
self.assertRegex(contract["storeMessageId"], msg_id_regex)
self.assertRegex(contract["instantiateMessageId"], msg_id_regex)


if __name__ == "__main__":
Expand Down

0 comments on commit 9f1d4b5

Please sign in to comment.