def test_get_latest_request(requests_mock): requests_mock.register_uri( "GET", "{}/oracle/request_search?oid=8&ask_count=4&min_count=3&calldata=000000190000000652454e4254430000000457425443000000034449410000000342544d00000004494f545800000003464554000000034a5354000000034d434f000000034b4d440000000342545300000003514b430000000559414d563200000003585a4300000003554f5300000004414b524f00000003484e5400000003484f54000000034b4149000000034f474e00000003575258000000034b4441000000034f524e00000003464f52000000034153540000000553544f524a000000003b9aca00".format( TEST_RPC ), json={ "height": "2243612", "result": { "request": { "oracle_script_id": "8", "calldata": "AAAAGQAAAAZSRU5CVEMAAAAEV0JUQwAAAANESUEAAAADQlRNAAAABElPVFgAAAADRkVUAAAAA0pTVAAAAANNQ08AAAADS01EAAAAA0JUUwAAAANRS0MAAAAFWUFNVjIAAAADWFpDAAAAA1VPUwAAAARBS1JPAAAAA0hOVAAAAANIT1QAAAADS0FJAAAAA09HTgAAAANXUlgAAAADS0RBAAAAA09STgAAAANGT1IAAAADQVNUAAAABVNUT1JKAAAAADuaygA=", "requested_validators": [ "bandvaloper1xnryftxluq49fk52c5j5zrxcc5rzye96s70msl", "bandvaloper1v38hewjc0865dm4t89v5efh9rmum5rmrm7evg4", "bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw", "bandvaloper1yyv5jkqaukq0ajqn7vhkyhpff7h6e99j3gv0tr", ], "min_count": "3", "request_height": "2243579", "request_time": "2020-10-22T08:12:00.558933096Z", "client_id": "bandteam", "raw_requests": [ { "external_id": "2", "data_source_id": "15", "calldata": "UkVOQlRDIFdCVEMgRElBIEJUTSBJT1RYIEZFVCBKU1QgTUNPIEtNRCBCVFMgUUtDIFlBTVYyIFhaQyBVT1MgQUtSTyBITlQgSE9UIEtBSSBPR04gV1JYIEtEQSBPUk4gRk9SIEFTVCBTVE9SSg==", }, { "data_source_id": "11", "calldata": "V0JUQyBESUEgQlRNIElPVFggRkVUIEpTVCBNQ08gS01EIEJUUyBRS0MgWUFNVjIgWFpDIEFLUk8gS0FJIE9HTiBXUlggS0RBIEZPUiBBU1QgU1RPUko=", }, { "external_id": "1", "data_source_id": "12", "calldata": "UkVOQlRDIFdCVEMgRElBIEJUTSBJT1RYIEZFVCBKU1QgTUNPIEtNRCBCVFMgUUtDIFlBTVYyIFhaQyBVT1MgQUtSTyBITlQgSE9UIEtBSSBPR04gV1JYIEtEQSBPUk4gRk9SIEFTVCBTVE9SSg==", }, ], }, "reports": [ { "validator": "bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw", "in_before_resolve": True, "raw_reports": [ { "external_id": "2", "data": "MTMwMTQuNjgzNCwxMjc2OC45NTUzLDEuMjMyODUyLDAuMDYzNDI4NjMsMC4wMDYxNjgwMSwwLjA1MDM1OTQxLDAuMDI1ODk3MDksMi45MDUzNzQsMC40OTUwODAyMSwwLjAxOTIyNjE2LDAuMDA0ODg4NTcsOC4wNDk2NzIsNC4wNTM2MTcsMC4wOTg0NDAyMSwwLjAxMjgxMDk0LDEuMTA4MDczLDAuMDAwNTIzNjUsMC4wMTY4NTAzOSwwLjE4MDg4ODAyLDAuMDk0MjM3MzUsMC4yMDI3NDQxLDEuNzA4ODQ1LDAuMDMxNzgwNzEsMC4xMjUyNTE5NywwLjM4MQ==", }, { "external_id": "1", "data": "MTI3NDkuNDcsMTI3OTIuNjUsMS4yMywwLjA2MzIzMSwwLjAwNjIxMDMyLDAuMDUwMjQsMC4wMjU4MzYwOCwyLjksMC40OTczNDMsMC4wMTkzMjEwMSwwLjAwNTAxNjk0LDcuOTgsNC4wNywwLjA5Nzc1NywwLjAxMjc5ODE4LDEuMTIsMC4wMDA1MjM5OSwwLjAxNjgwMTQzLDAuMTgxNTksMC4wOTM5LDAuMjAyNDAyLDEuNzUsMC4wMzE2NjEzOCwwLjEyMTA5MSwwLjM4MjAxNQo=", }, { "data": "MTI3OTMuMzgsMS4yNDMsMC4wNjMzNCwwLjAwNjI3LDAuMDQ5NzgsMC4wMjU4NSwyLjkwNywwLjQ5NjQsMC4wMTkzMiwwLjAwNTExOSw4LjEzMyw0LjA2MywwLjAxMjU0LDAuMDE3MSwwLjE4MywwLjA5MzgsMC4yMDczLDAuMDMyNzYsMC4xMjU4LDAuMzg0Mwo=" }, ], }, { "validator": "bandvaloper1yyv5jkqaukq0ajqn7vhkyhpff7h6e99j3gv0tr", "in_before_resolve": True, "raw_reports": [ { "external_id": "1", "data": "MTI3NDkuNDcsMTI3OTIuNjUsMS4yMywwLjA2MzIzMSwwLjAwNjIxMDMyLDAuMDUwMjQsMC4wMjU4MzYwOCwyLjksMC40OTczNDMsMC4wMTkzMjEwMSwwLjAwNTAxNjk0LDcuOTgsNC4wNywwLjA5Nzc1NywwLjAxMjc5ODE4LDEuMTIsMC4wMDA1MjM5OSwwLjAxNjgwMTQzLDAuMTgxNTksMC4wOTM5LDAuMjAyNDAyLDEuNzUsMC4wMzE2NjEzOCwwLjEyMTA5MSwwLjM4MjAxNQo=", }, { "external_id": "2", "data": "MTMwMTQuNjgzNCwxMjc2OC45NTUzLDEuMjMyODUyLDAuMDYzNDI4NjMsMC4wMDYxNjgwMSwwLjA1MDM1OTQxLDAuMDI1ODk3MDksMi45MDUzNzQsMC40OTUwODAyMSwwLjAxOTIyNjE2LDAuMDA0ODg4NTcsOC4wNDk2NzIsNC4wNTM2MTcsMC4wOTg0NDAyMSwwLjAxMjgxMDk0LDEuMTA4MDczLDAuMDAwNTIzNjUsMC4wMTY4NTAzOSwwLjE4MDg4ODAyLDAuMDk0MjM3MzUsMC4yMDI3NDQxLDEuNzA4ODQ1LDAuMDMxNzgwNzEsMC4xMjUyNTE5NywwLjM4MQ==", }, { "data": "MTI3OTMuMzgsMS4yNDMsMC4wNjMzNCwwLjAwNjI3LDAuMDQ5NzgsMC4wMjU4NSwyLjkxMSwwLjQ5NjQsMC4wMTkzMiwwLjAwNTExOSw4LjEzMyw0LjA2MywwLjAxMjU0LDAuMDE3MSwwLjE4MywwLjA5MzgsMC4yMDczLDAuMDMyNzYsMC4xMjU4LDAuMzg0Mwo=" }, ], }, { "validator": "bandvaloper1xnryftxluq49fk52c5j5zrxcc5rzye96s70msl", "in_before_resolve": True, "raw_reports": [ { "external_id": "1", "data": "MTI3NDkuNDcsMTI3OTIuNjUsMS4yMywwLjA2MzIzMSwwLjAwNjIxMDMyLDAuMDUwMjQsMC4wMjU4MzYwOCwyLjksMC40OTczNDMsMC4wMTkzMjEwMSwwLjAwNTAxNjk0LDcuOTgsNC4wNywwLjA5Nzc1NywwLjAxMjc5ODE4LDEuMTIsMC4wMDA1MjM5OSwwLjAxNjgwMTQzLDAuMTgxNTksMC4wOTM5LDAuMjAyNDAyLDEuNzUsMC4wMzE2NjEzOCwwLjEyMTA5MSwwLjM4MjAxNQo=", }, { "external_id": "2", "data": "MTMwMTQuNjgzNCwxMjc2OC45NTUzLDEuMjMyODUyLDAuMDYzNDI4NjMsMC4wMDYxNjgwMSwwLjA1MDM1OTQxLDAuMDI1ODk3MDksMi45MDUzNzQsMC40OTUwODAyMSwwLjAxOTIyNjE2LDAuMDA0ODg4NTcsOC4wNDk2NzIsNC4wNTM2MTcsMC4wOTg0NDAyMSwwLjAxMjgxMDk0LDEuMTA4MDczLDAuMDAwNTIzNjUsMC4wMTY4NTAzOSwwLjE4MDg4ODAyLDAuMDk0MjM3MzUsMC4yMDI3NDQxLDEuNzA4ODQ1LDAuMDMxNzgwNzEsMC4xMjUyNTE5NywwLjM4MQ==", }, { "data": "MTI3OTMuMzgsMS4yNDMsMC4wNjMzNCwwLjAwNjI3LDAuMDQ5NzgsMC4wMjU4NSwyLjkxMSwwLjQ5NjQsMC4wMTkzMiwwLjAwNTExOSw4LjEzMyw0LjA2MywwLjAxMjU0LDAuMDE3MSwwLjE4MywwLjA5MzgsMC4yMDczLDAuMDMyNzYsMC4xMjU4LDAuMzg0Mwo=" }, ], }, { "validator": "bandvaloper1v38hewjc0865dm4t89v5efh9rmum5rmrm7evg4", "in_before_resolve": True, "raw_reports": [ { "external_id": "2", "data": "MTMwMTQuNjgzNCwxMjc2OC45NTUzLDEuMjMyODUyLDAuMDYzNDI4NjMsMC4wMDYxNjgwMSwwLjA1MDM1OTQxLDAuMDI1ODk3MDksMi45MDUzNzQsMC40OTUwODAyMSwwLjAxOTIyNjE2LDAuMDA0ODg4NTcsOC4wNDk2NzIsNC4wNTM2MTcsMC4wOTg0NDAyMSwwLjAxMjgxMDk0LDEuMTA4MDczLDAuMDAwNTIzNjUsMC4wMTY4NTAzOSwwLjE4MDg4ODAyLDAuMDk0MjM3MzUsMC4yMDI3NDQxLDEuNzA4ODQ1LDAuMDMxNzgwNzEsMC4xMjUyNTE5NywwLjM4MQ==", }, { "external_id": "1", "data": "MTI3NDkuNDcsMTI3OTIuNjUsMS4yMywwLjA2MzIzMSwwLjAwNjIxMDMyLDAuMDUwMjQsMC4wMjU4MzYwOCwyLjksMC40OTczNDMsMC4wMTkzMjEwMSwwLjAwNTAxNjk0LDcuOTgsNC4wNywwLjA5Nzc1NywwLjAxMjc5ODE4LDEuMTIsMC4wMDA1MjM5OSwwLjAxNjgwMTQzLDAuMTgxNTksMC4wOTM5LDAuMjAyNDAyLDEuNzUsMC4wMzE2NjEzOCwwLjEyMTA5MSwwLjM4MjAxNQo=", }, { "data": "MTI3OTMuMzgsMS4yNDMsMC4wNjMzNCwwLjAwNjI3LDAuMDQ5NzgsMC4wMjU4NSwyLjkxMSwwLjQ5NjQsMC4wMTkzMiwwLjAwNTExOSw4LjEzMyw0LjA2MywwLjAxMjU0LDAuMDE3MSwwLjE4MywwLjA5MzgsMC4yMDczLDAuMDMyNzYsMC4xMjU4LDAuMzg0Mwo=" }, ], }, ], "result": { "request_packet_data": { "client_id": "bandteam", "oracle_script_id": "8", "calldata": "AAAAGQAAAAZSRU5CVEMAAAAEV0JUQwAAAANESUEAAAADQlRNAAAABElPVFgAAAADRkVUAAAAA0pTVAAAAANNQ08AAAADS01EAAAAA0JUUwAAAANRS0MAAAAFWUFNVjIAAAADWFpDAAAAA1VPUwAAAARBS1JPAAAAA0hOVAAAAANIT1QAAAADS0FJAAAAA09HTgAAAANXUlgAAAADS0RBAAAAA09STgAAAANGT1IAAAADQVNUAAAABVNUT1JKAAAAADuaygA=", "ask_count": "4", "min_count": "3", }, "response_packet_data": { "client_id": "bandteam", "request_id": "754674", "ans_count": "4", "request_time": "1603354320", "resolve_time": "1603354323", "resolve_status": 1, "result": "AAAAGQAAC7dXmw1gAAALooVb5oAAAAAASXvUIAAAAAADxn3fAAAAAABewxAAAAAAAv6aAAAAAAABinCQAAAAAK0sfTAAAAAAHZZ2gAAAAAABJszAAAAAAABMjWwAAAAB38w/PwAAAADyLHW/AAAAAAXY3a0AAAAAAMNI5AAAAABCZtkUAAAAAAAH/isAAAAAAQEd1gAAAAAK0tfwAAAAAAWYzOAAAAAADBWhJAAAAABnFOSkAAAAAAHk72UAAAAAB3cxgQAAAAAWxRYY", }, }, }, }, status_code=200, ) assert client.get_latest_request( oid=8, calldata=bytes.fromhex( "000000190000000652454e4254430000000457425443000000034449410000000342544d00000004494f545800000003464554000000034a5354000000034d434f000000034b4d440000000342545300000003514b430000000559414d563200000003585a4300000003554f5300000004414b524f00000003484e5400000003484f54000000034b4149000000034f474e00000003575258000000034b4441000000034f524e00000003464f52000000034153540000000553544f524a000000003b9aca00" ), min_count=3, ask_count=4, ) == RequestInfo( request=Request( oracle_script_id=8, requested_validators=[ "bandvaloper1xnryftxluq49fk52c5j5zrxcc5rzye96s70msl", "bandvaloper1v38hewjc0865dm4t89v5efh9rmum5rmrm7evg4", "bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw", "bandvaloper1yyv5jkqaukq0ajqn7vhkyhpff7h6e99j3gv0tr", ], min_count=3, request_height=2243579, raw_requests=[ RawRequest( data_source_id=15, external_id=2, calldata=b"RENBTC WBTC DIA BTM IOTX FET JST MCO KMD BTS QKC YAMV2 XZC UOS AKRO HNT HOT KAI OGN WRX KDA ORN FOR AST STORJ", ), RawRequest( data_source_id=11, external_id=0, calldata=b"WBTC DIA BTM IOTX FET JST MCO KMD BTS QKC YAMV2 XZC AKRO KAI OGN WRX KDA FOR AST STORJ", ), RawRequest( data_source_id=12, external_id=1, calldata=b"RENBTC WBTC DIA BTM IOTX FET JST MCO KMD BTS QKC YAMV2 XZC UOS AKRO HNT HOT KAI OGN WRX KDA ORN FOR AST STORJ", ), ], client_id="bandteam", calldata=b"\x00\x00\x00\x19\x00\x00\x00\x06RENBTC\x00\x00\x00\x04WBTC\x00\x00\x00\x03DIA\x00\x00\x00\x03BTM\x00\x00\x00\x04IOTX\x00\x00\x00\x03FET\x00\x00\x00\x03JST\x00\x00\x00\x03MCO\x00\x00\x00\x03KMD\x00\x00\x00\x03BTS\x00\x00\x00\x03QKC\x00\x00\x00\x05YAMV2\x00\x00\x00\x03XZC\x00\x00\x00\x03UOS\x00\x00\x00\x04AKRO\x00\x00\x00\x03HNT\x00\x00\x00\x03HOT\x00\x00\x00\x03KAI\x00\x00\x00\x03OGN\x00\x00\x00\x03WRX\x00\x00\x00\x03KDA\x00\x00\x00\x03ORN\x00\x00\x00\x03FOR\x00\x00\x00\x03AST\x00\x00\x00\x05STORJ\x00\x00\x00\x00;\x9a\xca\x00", ), reports=[ Report( validator="bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw", raw_reports=[ RawReport( external_id=2, data=b"13014.6834,12768.9553,1.232852,0.06342863,0.00616801,0.05035941,0.02589709,2.905374,0.49508021,0.01922616,0.00488857,8.049672,4.053617,0.09844021,0.01281094,1.108073,0.00052365,0.01685039,0.18088802,0.09423735,0.2027441,1.708845,0.03178071,0.12525197,0.381", ), RawReport( external_id=1, data=b"12749.47,12792.65,1.23,0.063231,0.00621032,0.05024,0.02583608,2.9,0.497343,0.01932101,0.00501694,7.98,4.07,0.097757,0.01279818,1.12,0.00052399,0.01680143,0.18159,0.0939,0.202402,1.75,0.03166138,0.121091,0.382015\n", ), RawReport( external_id=0, data=b"12793.38,1.243,0.06334,0.00627,0.04978,0.02585,2.907,0.4964,0.01932,0.005119,8.133,4.063,0.01254,0.0171,0.183,0.0938,0.2073,0.03276,0.1258,0.3843\n", ), ], in_before_resolve=True, ), Report( validator="bandvaloper1yyv5jkqaukq0ajqn7vhkyhpff7h6e99j3gv0tr", raw_reports=[ RawReport( external_id=1, data=b"12749.47,12792.65,1.23,0.063231,0.00621032,0.05024,0.02583608,2.9,0.497343,0.01932101,0.00501694,7.98,4.07,0.097757,0.01279818,1.12,0.00052399,0.01680143,0.18159,0.0939,0.202402,1.75,0.03166138,0.121091,0.382015\n", ), RawReport( external_id=2, data=b"13014.6834,12768.9553,1.232852,0.06342863,0.00616801,0.05035941,0.02589709,2.905374,0.49508021,0.01922616,0.00488857,8.049672,4.053617,0.09844021,0.01281094,1.108073,0.00052365,0.01685039,0.18088802,0.09423735,0.2027441,1.708845,0.03178071,0.12525197,0.381", ), RawReport( external_id=0, data=b"12793.38,1.243,0.06334,0.00627,0.04978,0.02585,2.911,0.4964,0.01932,0.005119,8.133,4.063,0.01254,0.0171,0.183,0.0938,0.2073,0.03276,0.1258,0.3843\n", ), ], in_before_resolve=True, ), Report( validator="bandvaloper1xnryftxluq49fk52c5j5zrxcc5rzye96s70msl", raw_reports=[ RawReport( external_id=1, data=b"12749.47,12792.65,1.23,0.063231,0.00621032,0.05024,0.02583608,2.9,0.497343,0.01932101,0.00501694,7.98,4.07,0.097757,0.01279818,1.12,0.00052399,0.01680143,0.18159,0.0939,0.202402,1.75,0.03166138,0.121091,0.382015\n", ), RawReport( external_id=2, data=b"13014.6834,12768.9553,1.232852,0.06342863,0.00616801,0.05035941,0.02589709,2.905374,0.49508021,0.01922616,0.00488857,8.049672,4.053617,0.09844021,0.01281094,1.108073,0.00052365,0.01685039,0.18088802,0.09423735,0.2027441,1.708845,0.03178071,0.12525197,0.381", ), RawReport( external_id=0, data=b"12793.38,1.243,0.06334,0.00627,0.04978,0.02585,2.911,0.4964,0.01932,0.005119,8.133,4.063,0.01254,0.0171,0.183,0.0938,0.2073,0.03276,0.1258,0.3843\n", ), ], in_before_resolve=True, ), Report( validator="bandvaloper1v38hewjc0865dm4t89v5efh9rmum5rmrm7evg4", raw_reports=[ RawReport( external_id=2, data=b"13014.6834,12768.9553,1.232852,0.06342863,0.00616801,0.05035941,0.02589709,2.905374,0.49508021,0.01922616,0.00488857,8.049672,4.053617,0.09844021,0.01281094,1.108073,0.00052365,0.01685039,0.18088802,0.09423735,0.2027441,1.708845,0.03178071,0.12525197,0.381", ), RawReport( external_id=1, data=b"12749.47,12792.65,1.23,0.063231,0.00621032,0.05024,0.02583608,2.9,0.497343,0.01932101,0.00501694,7.98,4.07,0.097757,0.01279818,1.12,0.00052399,0.01680143,0.18159,0.0939,0.202402,1.75,0.03166138,0.121091,0.382015\n", ), RawReport( external_id=0, data=b"12793.38,1.243,0.06334,0.00627,0.04978,0.02585,2.911,0.4964,0.01932,0.005119,8.133,4.063,0.01254,0.0171,0.183,0.0938,0.2073,0.03276,0.1258,0.3843\n", ), ], in_before_resolve=True, ), ], result=Result( request_packet_data=RequestPacketData( oracle_script_id=8, ask_count=4, min_count=3, client_id="bandteam", calldata=b"\x00\x00\x00\x19\x00\x00\x00\x06RENBTC\x00\x00\x00\x04WBTC\x00\x00\x00\x03DIA\x00\x00\x00\x03BTM\x00\x00\x00\x04IOTX\x00\x00\x00\x03FET\x00\x00\x00\x03JST\x00\x00\x00\x03MCO\x00\x00\x00\x03KMD\x00\x00\x00\x03BTS\x00\x00\x00\x03QKC\x00\x00\x00\x05YAMV2\x00\x00\x00\x03XZC\x00\x00\x00\x03UOS\x00\x00\x00\x04AKRO\x00\x00\x00\x03HNT\x00\x00\x00\x03HOT\x00\x00\x00\x03KAI\x00\x00\x00\x03OGN\x00\x00\x00\x03WRX\x00\x00\x00\x03KDA\x00\x00\x00\x03ORN\x00\x00\x00\x03FOR\x00\x00\x00\x03AST\x00\x00\x00\x05STORJ\x00\x00\x00\x00;\x9a\xca\x00", ), response_packet_data=ResponsePacketData( request_id=754674, request_time=1603354320, resolve_time=1603354323, resolve_status=1, ans_count=4, client_id="bandteam", result=b"\x00\x00\x00\x19\x00\x00\x0b\xb7W\x9b\r`\x00\x00\x0b\xa2\x85[\xe6\x80\x00\x00\x00\x00I{\xd4 \x00\x00\x00\x00\x03\xc6}\xdf\x00\x00\x00\x00\x00^\xc3\x10\x00\x00\x00\x00\x02\xfe\x9a\x00\x00\x00\x00\x00\x01\x8ap\x90\x00\x00\x00\x00\xad,}0\x00\x00\x00\x00\x1d\x96v\x80\x00\x00\x00\x00\x01&\xcc\xc0\x00\x00\x00\x00\x00L\x8dl\x00\x00\x00\x01\xdf\xcc??\x00\x00\x00\x00\xf2,u\xbf\x00\x00\x00\x00\x05\xd8\xdd\xad\x00\x00\x00\x00\x00\xc3H\xe4\x00\x00\x00\x00Bf\xd9\x14\x00\x00\x00\x00\x00\x07\xfe+\x00\x00\x00\x00\x01\x01\x1d\xd6\x00\x00\x00\x00\n\xd2\xd7\xf0\x00\x00\x00\x00\x05\x98\xcc\xe0\x00\x00\x00\x00\x0c\x15\xa1$\x00\x00\x00\x00g\x14\xe4\xa4\x00\x00\x00\x00\x01\xe4\xefe\x00\x00\x00\x00\x07w1\x81\x00\x00\x00\x00\x16\xc5\x16\x18", ), ), )
def test_verify(mock_client): auth = Auth(mock_client) # Fail signature verification assert (auth.verify( "bandchain", VALIDATOR_TEST, "2", "1", "bandpub1addwnpepqgugvxy0ueqwfmlzh2ta5at2lumcy4wpzzjs4hjz8j44lrdcryqs66wh3rp", "IsgagGxxSVHOPyzProTYBW9sFNMjLGkuDm+JvLgBH8Ux6GMpj3p6e5YGY8KRVWV3fdYWm/UBZdpVqsMbnpV6PQ==", ) == False) # Wrong chain id mock_client.get_chain_id.return_value = "fake_id" assert (auth.verify( "bandchain", VALIDATOR_TEST, "1", "1", "bandpub1addwnpepqgugvxy0ueqwfmlzh2ta5at2lumcy4wpzzjs4hjz8j44lrdcryqs66wh3rp", "IsgagGxxSVHOPyzProTYBW9sFNMjLGkuDm+JvLgBH8Ux6GMpj3p6e5YGY8KRVWV3fdYWm/UBZdpVqsMbnpV6PQ==", ) == False) mock_client.get_chain_id.return_value = "bandchain" # Unauthorized reporter mock_client.get_reporters.return_value = [ "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c", "band1ath4dk8e4fwqs5qmp3nnxspar5q0arrtpxy8lx", ] assert (auth.verify( "bandchain", VALIDATOR_TEST, "1", "1", "bandpub1addwnpepqgugvxy0ueqwfmlzh2ta5at2lumcy4wpzzjs4hjz8j44lrdcryqs66wh3rp", "IsgagGxxSVHOPyzProTYBW9sFNMjLGkuDm+JvLgBH8Ux6GMpj3p6e5YGY8KRVWV3fdYWm/UBZdpVqsMbnpV6PQ==", ) == False) mock_client.get_reporters.return_value = [ "band1wmvh4uzemujfap5graugzckeazr39uy6lesd0g" ] # Expired request mock_client.get_request_by_id.return_value = REQUEST_TEST mock_client.get_latest_block.return_value = { "block": { "header": { "height": 136730 } } } assert (auth.verify( "bandchain", VALIDATOR_TEST, "1", "1", "bandpub1addwnpepqgugvxy0ueqwfmlzh2ta5at2lumcy4wpzzjs4hjz8j44lrdcryqs66wh3rp", "IsgagGxxSVHOPyzProTYBW9sFNMjLGkuDm+JvLgBH8Ux6GMpj3p6e5YGY8KRVWV3fdYWm/UBZdpVqsMbnpV6PQ==", ) == False) mock_client.get_latest_block.return_value = { "block": { "header": { "height": 136639 } } } request = copy.deepcopy(REQUEST_TEST) request.request.requested_validators = request.request.requested_validators[: -1] mock_client.get_request_by_id.return_value = request assert (auth.verify( "bandchain", VALIDATOR_TEST, "1", "1", "bandpub1addwnpepqgugvxy0ueqwfmlzh2ta5at2lumcy4wpzzjs4hjz8j44lrdcryqs66wh3rp", "IsgagGxxSVHOPyzProTYBW9sFNMjLGkuDm+JvLgBH8Ux6GMpj3p6e5YGY8KRVWV3fdYWm/UBZdpVqsMbnpV6PQ==", ) == False) # Must return false if validator already reported data. request = copy.deepcopy(REQUEST_TEST) request.reports = [Report(VALIDATOR_TEST, [], True)] mock_client.get_request_by_id.return_value = request assert (auth.verify( "bandchain", VALIDATOR_TEST, "1", "1", "bandpub1addwnpepqgugvxy0ueqwfmlzh2ta5at2lumcy4wpzzjs4hjz8j44lrdcryqs66wh3rp", "IsgagGxxSVHOPyzProTYBW9sFNMjLGkuDm+JvLgBH8Ux6GMpj3p6e5YGY8KRVWV3fdYWm/UBZdpVqsMbnpV6PQ==", ) == False) mock_client.get_request_by_id.return_value = REQUEST_TEST assert (auth.verify( "bandchain", VALIDATOR_TEST, "1", "1", "bandpub1addwnpepqgugvxy0ueqwfmlzh2ta5at2lumcy4wpzzjs4hjz8j44lrdcryqs66wh3rp", "IsgagGxxSVHOPyzProTYBW9sFNMjLGkuDm+JvLgBH8Ux6GMpj3p6e5YGY8KRVWV3fdYWm/UBZdpVqsMbnpV6PQ==", ) == True)
def test_get_request_by_id(requests_mock): requests_mock.register_uri( "GET", "{}/oracle/requests/1".format(TEST_RPC), json={ "height": "651397", "result": { "request": { "oracle_script_id": "1", "calldata": "AAAAA0JUQwAAAAAAAABk", "requested_validators": ["bandvaloper1j9vk75jjty02elhwqqjehaspfslaem8pr20qst"], "min_count": "1", "request_height": "118", "request_time": "2020-10-14T09:47:23.818758882Z", "client_id": "from_scan", "raw_requests": [ {"external_id": "1", "data_source_id": "1", "calldata": "QlRD"}, {"external_id": "2", "data_source_id": "2", "calldata": "QlRD"}, {"external_id": "3", "data_source_id": "3", "calldata": "QlRD"}, ], }, "reports": [ { "validator": "bandvaloper1j9vk75jjty02elhwqqjehaspfslaem8pr20qst", "in_before_resolve": True, "raw_reports": [ {"external_id": "3", "data": "MTE0MTQuNTQ1Cg=="}, {"external_id": "1", "data": "MTE0MjAuNjEK"}, {"external_id": "2", "data": "MTE0MjQuMTgK"}, ], } ], "result": { "request_packet_data": { "client_id": "from_scan", "oracle_script_id": "1", "calldata": "AAAAA0JUQwAAAAAAAABk", "ask_count": "1", "min_count": "1", }, "response_packet_data": { "client_id": "from_scan", "request_id": "1", "ans_count": "1", "request_time": "1602668843", "resolve_time": "1602668845", "resolve_status": 1, "result": "AAAAAAARbNk=", }, }, }, }, status_code=200, ) assert client.get_request_by_id(1) == RequestInfo( request=Request( oracle_script_id=1, requested_validators=["bandvaloper1j9vk75jjty02elhwqqjehaspfslaem8pr20qst"], min_count=1, request_height=118, raw_requests=[ RawRequest(data_source_id=1, external_id=1, calldata=b"BTC"), RawRequest(data_source_id=2, external_id=2, calldata=b"BTC"), RawRequest(data_source_id=3, external_id=3, calldata=b"BTC"), ], client_id="from_scan", calldata=b"\x00\x00\x00\x03BTC\x00\x00\x00\x00\x00\x00\x00d", ), reports=[ Report( validator="bandvaloper1j9vk75jjty02elhwqqjehaspfslaem8pr20qst", raw_reports=[ RawReport(external_id=3, data=b"11414.545\n"), RawReport(external_id=1, data=b"11420.61\n"), RawReport(external_id=2, data=b"11424.18\n"), ], in_before_resolve=True, ) ], result=Result( request_packet_data=RequestPacketData( oracle_script_id=1, ask_count=1, min_count=1, client_id="from_scan", calldata=b"\x00\x00\x00\x03BTC\x00\x00\x00\x00\x00\x00\x00d", ), response_packet_data=ResponsePacketData( request_id=1, request_time=1602668843, resolve_time=1602668845, resolve_status=1, ans_count=1, client_id="from_scan", result=b"\x00\x00\x00\x00\x00\x11l\xd9", ), ), )
1, [ "bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw", "bandvaloper1v38hewjc0865dm4t89v5efh9rmum5rmrm7evg4", "bandvaloper1alzj765pzuhtjkmslme4fdpeakc0036xnyjltn", "bandvaloper1yyv5jkqaukq0ajqn7vhkyhpff7h6e99j3gv0tr", "bandvaloper1p40yh3zkmhcv0ecqp3mcazy83sa57rgjde6wec", ], 3, 136629, [], "test", base64.b64decode("AAAABFVTRFQAAAADQ05ZAAAAAAAPQkA="), ), [ Report("bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw", [], False), Report("bandvaloper1yyv5jkqaukq0ajqn7vhkyhpff7h6e99j3gv0tr", [], True), ], Result( RequestPacketData( 1, 5, 3, "test", base64.b64decode("AAAABFVTRFQAAAADQ05ZAAAAAAAPQkA="), ), ResponsePacketData(3000, 1596950963, 1596950966, 1, 3, "test", base64.b64decode("AAAAAABqbB0=")), ), )