-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_aws_lambda.py
42 lines (33 loc) · 1.14 KB
/
test_aws_lambda.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
from aws_lambda import lambda_handler
from keygen.crypto_coin_factory import CoinFactory
def test_aws_lambda_keygen():
event = {"body": "{\"blockchain\":\"BTC\", \"quantity\": 10}"}
res = lambda_handler(event=event, context=None)
body = res['body']
body_json = json.loads(body)
data = body_json['data']
assert len(data) == 10
coin = data[0]
wif = coin['wif']
address = coin['address']
fetched_address = CoinFactory().get_coin_service('BTC').get_address(private_key=wif)
assert address == fetched_address
def test_aws_lambda_keygen_ada():
event = {"body": "{\"blockchain\":\"ADA\", \"quantity\": 10}"}
res = lambda_handler(event=event, context=None)
body = res['body']
body_json = json.loads(body)
data = body_json['data']
assert len(data) == 10
coin = data[0]
wif = coin['wif']
address = coin['address']
fetched_address = CoinFactory().get_coin_service('ADA').get_address(private_key=wif)
assert address == fetched_address
def main():
test_aws_lambda_keygen()
test_aws_lambda_keygen_ada()
print("Success!")
if __name__ == '__main__':
main()