Skip to content

Commit

Permalink
Merge pull request #189 from xeroc/release/20231123
Browse files Browse the repository at this point in the history
fix: allow maps to contain dicts
  • Loading branch information
xeroc authored Nov 23, 2023
2 parents 4173f45 + 341c17f commit e98271f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion graphenebase/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ def __bytes__(self):
def __str__(self):
r = []
for e in self.data:
r.append([str(e[0]), str(e[1])])
r.append([str(e[0]), JsonObj(str(e[1]))])
return json.dumps(r)


Expand Down
24 changes: 12 additions & 12 deletions tests/test_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,35 +228,35 @@ def test_uint8(self):
self.assertEqual(str(u), "10")

def test_uint16(self):
u = types.Uint16(2 ** 16 - 1)
u = types.Uint16(2**16 - 1)
self.assertEqual(bytes(u), b"\xff\xff")
self.assertEqual(str(u), str(2 ** 16 - 1))
self.assertEqual(str(u), str(2**16 - 1))

def test_uint32(self):
u = types.Uint32(2 ** 32 - 1)
u = types.Uint32(2**32 - 1)
self.assertEqual(bytes(u), b"\xff\xff\xff\xff")
self.assertEqual(str(u), str(2 ** 32 - 1))
self.assertEqual(str(u), str(2**32 - 1))

def test_uint64(self):
u = types.Uint64(2 ** 64 - 1)
u = types.Uint64(2**64 - 1)
self.assertEqual(bytes(u), b"\xff\xff\xff\xff\xff\xff\xff\xff")
self.assertEqual(str(u), str(2 ** 64 - 1))
self.assertEqual(str(u), str(2**64 - 1))

def test_int64(self):
u = types.Int64(2 ** 63 - 1)
u = types.Int64(2**63 - 1)
self.assertEqual(bytes(u), b"\xff\xff\xff\xff\xff\xff\xff\x7f")
self.assertEqual(str(u), str(9223372036854775807))

def test_int16(self):
u = types.Int16(2 ** 15 - 1)
u = types.Int16(2**15 - 1)
self.assertEqual(bytes(u), b"\xff\x7f")
self.assertEqual(str(u), str(2 ** 15 - 1))
self.assertEqual(str(u), str(2**15 - 1))

def test_varint32(self):
u = types.Varint32(2 ** 32 - 1)
u = types.Varint32(2**32 - 1)
self.assertEqual(bytes(u), b"\xff\xff\xff\xff\x0f")
self.assertEqual(str(u), str(4294967295))
u = types.Id(2 ** 32 - 1)
u = types.Id(2**32 - 1)
self.assertEqual(bytes(u), b"\xff\xff\xff\xff\x0f")
self.assertEqual(str(u), str(4294967295))

Expand Down Expand Up @@ -338,7 +338,7 @@ def json(self):
def test_Map(self):
u = types.Map([[types.Uint16(10), types.Uint16(11)]])
self.assertEqual(bytes(u), b"\x01\n\x00\x0b\x00")
self.assertEqual(str(u), '[["10", "11"]]')
self.assertEqual(str(u), '[["10", 11]]')

def test_voteid(self):
u = types.VoteId("0:30")
Expand Down

0 comments on commit e98271f

Please sign in to comment.