Skip to content

Commit c71fe90

Browse files
committed
fix: finish implementation testing of more operations
1 parent a8c3d60 commit c71fe90

File tree

4 files changed

+129
-55
lines changed

4 files changed

+129
-55
lines changed

bitsharesbase/objecttypes.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@
2121
object_type["custom_authority"] = 17
2222
object_type["ticket"] = 18
2323
object_type["liquidity_pool"] = 19
24-
object_type["OBJECT_TYPE_COUNT"] = 19
24+
object_type["samet_fund"] = 20
25+
object_type["credit_offer"] = 21
26+
object_type["credit_deal"] = 22
27+
object_type["OBJECT_TYPE_COUNT"] = 22

bitsharesbase/operationids.py

+14
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,20 @@
6565
"liquidity_pool_deposit",
6666
"liquidity_pool_withdraw",
6767
"liquidity_pool_exchange",
68+
"samet_fund_create",
69+
"samet_fund_delete",
70+
"samet_fund_update",
71+
"samet_fund_borrow",
72+
"samet_fund_repay",
73+
"credit_offer_create",
74+
"credit_offer_delete",
75+
"credit_offer_update",
76+
"credit_offer_accept",
77+
"credit_deal_repay",
78+
"credit_deal_expired",
79+
"liquidity_pool_update",
80+
"credit_deal_update",
81+
"limit_order_update",
6882
]
6983
operations = {o: ops.index(o) for o in ops}
7084

bitsharesbase/operations.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,22 @@
5454
class_namemap = {}
5555

5656

57+
class VirtualOperationException(Exception):
58+
pass
59+
60+
61+
class ChainParameters(NotImplementedError):
62+
pass
63+
64+
65+
class CustomRestriction(NotImplementedError):
66+
pass
67+
68+
69+
class VestingPolicy(NotImplementedError):
70+
pass
71+
72+
5773
def fill_classmaps():
5874
for name, ind in operations.items():
5975
classname = name[0:1].upper() + name[1:]
@@ -1746,7 +1762,7 @@ def __init__(self, *args, **kwargs):
17461762
Uint32(kwargs["max_duration_seconds"]),
17471763
),
17481764
("min_deal_amount", Int64(kwargs["min_deal_amount"])),
1749-
("enabled", Bool(kwargs["enabled"])(kwargs["enabled"])),
1765+
("enabled", Bool(kwargs["enabled"])),
17501766
("auto_disable_time", PointInTime(kwargs["auto_disable_time"])),
17511767
(
17521768
"acceptable_collateral",

tests/test_transactions.py

+94-53
Original file line numberDiff line numberDiff line change
@@ -1045,8 +1045,7 @@ def test_assert_b(self):
10451045
)
10461046
self.doit(0)
10471047

1048-
1049-
def test_samet_fund_create(self):
1048+
def test_samet_fund_create(self):
10501049
self.op = operations.Samet_fund_create(
10511050
**{
10521051
"fee": {"amount": 0, "asset_id": "1.3.0"},
@@ -1057,10 +1056,15 @@ def test_samet_fund_create(self):
10571056
"extensions": [],
10581057
}
10591058
)
1060-
self.cm = ('f68585abf4dce7c804570140000000000000000000b60200102700000000000001000000000001203431966ca7e7f40e921633cd767eece0ddefc5abb5224965cca6458dfa28572b687c459a2f4189bf1a41e13336fac6db10cc8c90215888948453b5063a8ccb9f')
1059+
self.cm = (
1060+
"f68585abf4dce7c804570140000000000000000000b60200102"
1061+
"700000000000001000000000001203431966ca7e7f40e921633"
1062+
"cd767eece0ddefc5abb5224965cca6458dfa28572b687c459a2"
1063+
"f4189bf1a41e13336fac6db10cc8c90215888948453b5063a8c"
1064+
"cb9f"
1065+
)
10611066
self.doit()
10621067

1063-
10641068
def test_samet_fund_delete(self):
10651069
self.op = operations.Samet_fund_delete(
10661070
**{
@@ -1070,10 +1074,14 @@ def test_samet_fund_delete(self):
10701074
"extensions": [],
10711075
}
10721076
)
1073-
self.cm = ('f68585abf4dce7c8045701410000000000000000007b010000011f4abefaf5a630eace47f6db44d6516c4e459e70cd89ba5988586d04be40646cf3723cf4b5979e5d094b819f94c37d19e4fac5a0aa20ba3ff8dab8d8482b5356d8')
1077+
self.cm = (
1078+
"f68585abf4dce7c8045701410000000000000000007b0100000"
1079+
"11f4abefaf5a630eace47f6db44d6516c4e459e70cd89ba5988"
1080+
"586d04be40646cf3723cf4b5979e5d094b819f94c37d19e4fac"
1081+
"5a0aa20ba3ff8dab8d8482b5356d8"
1082+
)
10741083
self.doit()
10751084

1076-
10771085
def test_samet_fund_update(self):
10781086
self.op = operations.Samet_fund_update(
10791087
**{
@@ -1085,10 +1093,14 @@ def test_samet_fund_update(self):
10851093
"extensions": [],
10861094
}
10871095
)
1088-
self.cm = ('f68585abf4dce7c8045701420000000000000000007b010001020000000000011f08656f260d4e4c6580202ab2520cad06cdc2539f03c3a74bcc3b6a8cdf2da5f84b252f09f15b77e825f5bb3fe7ff70a28d48516160653318beda6e156ba47987')
1096+
self.cm = (
1097+
"f68585abf4dce7c8045701420000000000000000007b0100010"
1098+
"20000000000011f08656f260d4e4c6580202ab2520cad06cdc2"
1099+
"539f03c3a74bcc3b6a8cdf2da5f84b252f09f15b77e825f5bb3"
1100+
"fe7ff70a28d48516160653318beda6e156ba47987"
1101+
)
10891102
self.doit()
10901103

1091-
10921104
def test_samet_fund_borrow(self):
10931105
self.op = operations.Samet_fund_borrow(
10941106
**{
@@ -1099,10 +1111,14 @@ def test_samet_fund_borrow(self):
10991111
"extensions": [],
11001112
}
11011113
)
1102-
self.cm = ('f68585abf4dce7c8045701430000000000000000007b010a00000000000000000000012007d969d65e15f9bb2c227fdd1baf74fbb0ce3e9ef197b386098188a78c5a1b992a1d7da0d39a91fb862536b53d719f02d88657cb21ae1c2ab55222d4814a893d')
1114+
self.cm = (
1115+
"f68585abf4dce7c8045701430000000000000000007b010a000"
1116+
"00000000000000000012007d969d65e15f9bb2c227fdd1baf74"
1117+
"fbb0ce3e9ef197b386098188a78c5a1b992a1d7da0d39a91fb8"
1118+
"62536b53d719f02d88657cb21ae1c2ab55222d4814a893d"
1119+
)
11031120
self.doit()
11041121

1105-
11061122
def test_samet_fund_repay(self):
11071123
self.op = operations.Samet_fund_repay(
11081124
**{
@@ -1114,10 +1130,15 @@ def test_samet_fund_repay(self):
11141130
"extensions": [],
11151131
}
11161132
)
1117-
self.cm = ('f68585abf4dce7c8045701440000000000000000007b010a00000000000000000a00000000000000000000011f573766a5dfe79df21d82df4a858a032d083e7b5db8f1d10cf6c0f48967965190607170df053d90fdf46f6fe1d10e160d292de03697136f91865588718a272e88')
1133+
self.cm = (
1134+
"f68585abf4dce7c8045701440000000000000000007b010a000"
1135+
"00000000000000a00000000000000000000011f573766a5dfe7"
1136+
"9df21d82df4a858a032d083e7b5db8f1d10cf6c0f4896796519"
1137+
"0607170df053d90fdf46f6fe1d10e160d292de03697136f9186"
1138+
"5588718a272e88"
1139+
)
11181140
self.doit()
11191141

1120-
11211142
def test_credit_offer_create(self):
11221143
self.op = operations.Credit_offer_create(
11231144
**{
@@ -1130,29 +1151,30 @@ def test_credit_offer_create(self):
11301151
"min_deal_amount": 1000,
11311152
"enabled": False,
11321153
"auto_disable_time": "2024-01-01T00:00:00",
1133-
"acceptable_collateral":
1134-
[[
1135-
"1.3.5589",
1136-
{
1137-
"base": {
1138-
"amount": 1, "asset_id": "1.3.0"
1154+
"acceptable_collateral": [
1155+
[
1156+
"1.3.5589",
1157+
{
1158+
"base": {"amount": 1, "asset_id": "1.3.0"},
1159+
"quote": {"amount": 250000, "asset_id": "1.3.5589"},
11391160
},
1140-
"quote": {
1141-
"amount": 250000, "asset_id": "1.3.5589"
1142-
}
1143-
}
1144-
]],
1145-
"acceptable_borrowers":
1146-
[
1147-
["1.2.100", 1000]
1161+
]
11481162
],
1163+
"acceptable_borrowers": [["1.2.100", 1000]],
11491164
"extensions": [],
11501165
}
11511166
)
1152-
self.cm = ()
1167+
self.cm = (
1168+
"f68585abf4dce7c8045701450000000000000000007b001027"
1169+
"00000000000001000000c0a80000e803000000000000008000"
1170+
"926501d52b01000000000000000090d0030000000000d52b01"
1171+
"64e80300000000000000000120107ea7f48037771b8243c5c9"
1172+
"a83ac3534128dbd1c47c4cf8bf8108e9a1bacede2d4e5f4254"
1173+
"2d298ece03008c3d5be75716338165e9adc8c1ebc245d70429"
1174+
"6df3"
1175+
)
11531176
self.doit(1)
11541177

1155-
11561178
def test_credit_offer_delete(self):
11571179
self.op = operations.Credit_offer_delete(
11581180
**{
@@ -1162,10 +1184,14 @@ def test_credit_offer_delete(self):
11621184
"extensions": [],
11631185
}
11641186
)
1165-
self.cm = ('f68585abf4dce7c8045701460000000000000000007b010000012042aed7548e971617836c55d55c57b5ecd15e2ef8ed1cdf56c380891ce10e2aaa743e3665de606a7833145a1a2dbe5b60870396972e9e5c803040ee4cec8a8772')
1187+
self.cm = (
1188+
"f68585abf4dce7c8045701460000000000000000007b0100000"
1189+
"12042aed7548e971617836c55d55c57b5ecd15e2ef8ed1cdf56"
1190+
"c380891ce10e2aaa743e3665de606a7833145a1a2dbe5b60870"
1191+
"396972e9e5c803040ee4cec8a8772"
1192+
)
11661193
self.doit()
11671194

1168-
11691195
def test_credit_offer_update(self):
11701196
self.op = operations.Credit_offer_update(
11711197
**{
@@ -1178,29 +1204,30 @@ def test_credit_offer_update(self):
11781204
"min_deal_amount": 10,
11791205
"enabled": True,
11801206
"auto_disable_time": "2024-01-01T00:00:00",
1181-
"acceptable_collateral":
1182-
[[
1183-
"1.3.5589",
1184-
{
1185-
"base": {
1186-
"amount": 1, "asset_id": "1.3.0"
1207+
"acceptable_collateral": [
1208+
[
1209+
"1.3.5589",
1210+
{
1211+
"base": {"amount": 1, "asset_id": "1.3.0"},
1212+
"quote": {"amount": 250000, "asset_id": "1.3.5589"},
11871213
},
1188-
"quote": {
1189-
"amount": 250000, "asset_id": "1.3.5589"
1190-
}
1191-
}
1192-
]],
1193-
"acceptable_borrowers":
1194-
[
1195-
["1.2.100", 1000]
1214+
]
11961215
],
1216+
"acceptable_borrowers": [["1.2.100", 1000]],
11971217
"extensions": [],
11981218
}
11991219
)
1200-
self.cm = ()
1220+
self.cm = (
1221+
"f68585abf4dce7c8045701470000000000000000007b010100"
1222+
"0000000000000000010100000001e8030000010a0000000000"
1223+
"0000010101800092650101d52b01000000000000000090d003"
1224+
"0000000000d52b010164e8030000000000000000012064575b"
1225+
"5fd2347411a643c54a2aaf2550c0c5653334ec81ca28a1e68f"
1226+
"fd7e7fd07748121135e01947ae317e3b7ae9263149b96e9630"
1227+
"1b16571984b94f7c72ebd9"
1228+
)
12011229
self.doit(1)
12021230

1203-
12041231
def test_credit_offer_accept(self):
12051232
self.op = operations.Credit_offer_accept(
12061233
**{
@@ -1214,10 +1241,15 @@ def test_credit_offer_accept(self):
12141241
"extensions": [],
12151242
}
12161243
)
1217-
self.cm = ('f68585abf4dce7c8045701480000000000000000007b0100000000000000000000000000000000000001000000e8030000000001201dda600d9efc172ee7e0ca6a2b1279709184d0bb0960afd93b49f60f8d90caed6b0f84de19ee54d7434ee11ec0af1f45415f4b024adbf0ca59a9e167eab3901b')
1244+
self.cm = (
1245+
"f68585abf4dce7c8045701480000000000000000007b0100000"
1246+
"000000000000000000000000000000001000000e80300000000"
1247+
"01201dda600d9efc172ee7e0ca6a2b1279709184d0bb0960afd"
1248+
"93b49f60f8d90caed6b0f84de19ee54d7434ee11ec0af1f4541"
1249+
"5f4b024adbf0ca59a9e167eab3901b"
1250+
)
12181251
self.doit()
12191252

1220-
12211253
def test_credit_deal_repay(self):
12221254
self.op = operations.Credit_deal_repay(
12231255
**{
@@ -1229,10 +1261,15 @@ def test_credit_deal_repay(self):
12291261
"extensions": [],
12301262
}
12311263
)
1232-
self.cm = ('f68585abf4dce7c8045701490000000000000000007bb412000000000000000000000000000000000000000001203ba717f69b6ed214ef1a105bda7756149cee25c0c92c48a7f2d59dee88997cec3f9254df2bd2476cf2df16b10ebca0937f8daf2eecccfb8848e4faed9b8c0df7')
1264+
self.cm = (
1265+
"f68585abf4dce7c8045701490000000000000000007bb412000"
1266+
"000000000000000000000000000000000000001203ba717f69b"
1267+
"6ed214ef1a105bda7756149cee25c0c92c48a7f2d59dee88997"
1268+
"cec3f9254df2bd2476cf2df16b10ebca0937f8daf2eecccfb88"
1269+
"48e4faed9b8c0df7"
1270+
)
12331271
self.doit()
12341272

1235-
12361273
def test_credit_deal_expired(self):
12371274
self.op = operations.Credit_deal_expired(
12381275
**{
@@ -1246,10 +1283,15 @@ def test_credit_deal_expired(self):
12461283
"fee_rate": 1,
12471284
}
12481285
)
1249-
self.cm = ('f68585abf4dce7c80457014a000000000000000000b412017b7b000000000000000000000000000000000000010000000001207e5770f0fae74fc78bebbe5267583a824999d6356698ebce0a25e4a468bd3e356ca10920e3c4301537bd02205e63617546a5d8eded230655d170529801838a3f')
1286+
self.cm = (
1287+
"f68585abf4dce7c80457014a000000000000000000b412017b7"
1288+
"b00000000000000000000000000000000000001000000000120"
1289+
"7e5770f0fae74fc78bebbe5267583a824999d6356698ebce0a2"
1290+
"5e4a468bd3e356ca10920e3c4301537bd02205e63617546a5d8"
1291+
"eded230655d170529801838a3f"
1292+
)
12501293
self.doit()
12511294

1252-
12531295
def compareConstructedTX(self):
12541296
self.maxDiff = None
12551297
self.op = operations.Call_order_update(
@@ -1282,4 +1324,3 @@ def compareConstructedTX(self):
12821324
print("ist: %s" % txWire[:-130])
12831325
print(txWire[:-130] == self.cm[:-130])
12841326
self.assertEqual(self.cm[:-130], txWire[:-130])
1285-

0 commit comments

Comments
 (0)