def __init__(self, args): self.id = bytes_to_int(args['id']) self.maker = Address(args['maker']) self.pay_token = Address(args['pay_gem']) self.pay_amount = Wad(args['pay_amt']) self.buy_token = Address(args['buy_gem']) self.buy_amount = Wad(args['buy_amt']) self.timestamp = args['timestamp']
def __init__(self, args): self.id = bytes_to_int(args['id']) self.maker = Address(args['maker']) self.have_token = Address(args['haveToken']) self.have_amount = Wad(args['haveAmount']) self.want_token = Address(args['wantToken']) self.want_amount = Wad(args['wantAmount']) self.timestamp = args['timestamp']
def test_bytes_to_int(): assert bytes_to_int( bytes([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 ])) == 0 assert bytes_to_int( bytes([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 ])) == 1 assert bytes_to_int( bytes([ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01 ])) == 257 assert bytes_to_int(bytes([0x00])) == 0 assert bytes_to_int(bytes([0x01, 0x01])) == 257 assert bytes_to_int(bytes([0x00, 0x01, 0x01])) == 257 assert bytes_to_int(bytes([0x00, 0x00, 0x01, 0x01])) == 257 assert bytes_to_int( bytes([ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff ])) == 2**256 - 1
def test_bytes_to_int_from_string(): assert bytes_to_int('\x00') == 0 assert bytes_to_int('\x01') == 1 assert bytes_to_int('\x01\x01') == 257 assert bytes_to_int('\x00\x01\x01') == 257 assert bytes_to_int('\x00\x00\x01\x01') == 257