tigerbeetle-node 0.16.33 → 0.16.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -9
- package/dist/benchmark.js +1 -1
- package/dist/benchmark.js.map +1 -1
- package/dist/bin/aarch64-linux-gnu/client.node +0 -0
- package/dist/bin/aarch64-linux-musl/client.node +0 -0
- package/dist/bin/aarch64-macos/client.node +0 -0
- package/dist/bin/x86_64-linux-gnu/client.node +0 -0
- package/dist/bin/x86_64-linux-musl/client.node +0 -0
- package/dist/bin/x86_64-macos/client.node +0 -0
- package/dist/bin/x86_64-windows/client.node +0 -0
- package/dist/bindings.d.ts +9 -9
- package/dist/bindings.js +8 -8
- package/dist/bindings.js.map +1 -1
- package/dist/test.js +49 -20
- package/dist/test.js.map +1 -1
- package/package.json +1 -1
- package/src/benchmark.ts +8 -8
- package/src/bindings.ts +8 -8
- package/src/test.ts +51 -20
package/src/test.ts
CHANGED
|
@@ -52,6 +52,8 @@ const accountB: Account = {
|
|
|
52
52
|
timestamp: 0n // this will be set correctly by the TigerBeetle server
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
const BATCH_MAX = 8189;
|
|
56
|
+
|
|
55
57
|
const tests: Array<{ name: string, fn: () => Promise<void> }> = []
|
|
56
58
|
function test(name: string, fn: () => Promise<void>) {
|
|
57
59
|
tests.push({ name, fn })
|
|
@@ -105,6 +107,35 @@ test('error if timestamp is not set to 0n on account', async (): Promise<void> =
|
|
|
105
107
|
assert.deepStrictEqual(errors[0], { index: 0, result: CreateAccountError.timestamp_must_be_zero })
|
|
106
108
|
})
|
|
107
109
|
|
|
110
|
+
test('batch max size', async (): Promise<void> => {
|
|
111
|
+
const BATCH_SIZE = 10_000;
|
|
112
|
+
var transfers: Transfer[] = [];
|
|
113
|
+
for (var i=0; i<BATCH_SIZE;i++) {
|
|
114
|
+
transfers.push({
|
|
115
|
+
id: 0n,
|
|
116
|
+
debit_account_id: 0n,
|
|
117
|
+
credit_account_id: 0n,
|
|
118
|
+
amount: 0n,
|
|
119
|
+
user_data_128: 0n,
|
|
120
|
+
user_data_64: 0n,
|
|
121
|
+
user_data_32: 0,
|
|
122
|
+
pending_id: 0n,
|
|
123
|
+
timeout: 0,
|
|
124
|
+
ledger: 0,
|
|
125
|
+
code: 0,
|
|
126
|
+
flags: 0,
|
|
127
|
+
timestamp: 0n,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
try {
|
|
132
|
+
const results = await client.createTransfers(transfers);
|
|
133
|
+
assert.fail();
|
|
134
|
+
} catch (error) {
|
|
135
|
+
assert.strictEqual(error.message, "Too much data provided on this batch.");
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
|
|
108
139
|
test('can lookup accounts', async (): Promise<void> => {
|
|
109
140
|
const accounts = await client.lookupAccounts([accountA.id, accountB.id])
|
|
110
141
|
|
|
@@ -542,7 +573,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
542
573
|
code: 0,
|
|
543
574
|
timestamp_min: 0n,
|
|
544
575
|
timestamp_max: 0n,
|
|
545
|
-
limit:
|
|
576
|
+
limit: BATCH_MAX,
|
|
546
577
|
flags: AccountFilterFlags.credits | AccountFilterFlags.debits,
|
|
547
578
|
}
|
|
548
579
|
var transfers = await client.getAccountTransfers(filter)
|
|
@@ -569,7 +600,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
569
600
|
code: 0,
|
|
570
601
|
timestamp_min: 0n,
|
|
571
602
|
timestamp_max: 0n,
|
|
572
|
-
limit:
|
|
603
|
+
limit: BATCH_MAX,
|
|
573
604
|
flags: AccountFilterFlags.debits | AccountFilterFlags.reversed,
|
|
574
605
|
}
|
|
575
606
|
transfers = await client.getAccountTransfers(filter)
|
|
@@ -597,7 +628,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
597
628
|
code: 0,
|
|
598
629
|
timestamp_min: 0n,
|
|
599
630
|
timestamp_max: 0n,
|
|
600
|
-
limit:
|
|
631
|
+
limit: BATCH_MAX,
|
|
601
632
|
flags: AccountFilterFlags.credits | AccountFilterFlags.reversed,
|
|
602
633
|
}
|
|
603
634
|
transfers = await client.getAccountTransfers(filter)
|
|
@@ -771,7 +802,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
771
802
|
code: 0,
|
|
772
803
|
timestamp_min: 0n,
|
|
773
804
|
timestamp_max: 0n,
|
|
774
|
-
limit:
|
|
805
|
+
limit: BATCH_MAX,
|
|
775
806
|
flags: AccountFilterFlags.credits | AccountFilterFlags.debits,
|
|
776
807
|
}
|
|
777
808
|
assert.deepStrictEqual((await client.getAccountTransfers(filter)), [])
|
|
@@ -786,7 +817,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
786
817
|
code: 0,
|
|
787
818
|
timestamp_min: (1n << 64n) - 1n, // ulong max value
|
|
788
819
|
timestamp_max: 0n,
|
|
789
|
-
limit:
|
|
820
|
+
limit: BATCH_MAX,
|
|
790
821
|
flags: AccountFilterFlags.credits | AccountFilterFlags.debits,
|
|
791
822
|
}
|
|
792
823
|
assert.deepStrictEqual((await client.getAccountTransfers(filter)), [])
|
|
@@ -801,7 +832,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
801
832
|
code: 0,
|
|
802
833
|
timestamp_min: 0n,
|
|
803
834
|
timestamp_max: (1n << 64n) - 1n, // ulong max value
|
|
804
|
-
limit:
|
|
835
|
+
limit: BATCH_MAX,
|
|
805
836
|
flags: AccountFilterFlags.credits | AccountFilterFlags.debits,
|
|
806
837
|
}
|
|
807
838
|
assert.deepStrictEqual((await client.getAccountTransfers(filter)), [])
|
|
@@ -816,7 +847,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
816
847
|
code: 0,
|
|
817
848
|
timestamp_min: (1n << 64n) - 2n, // ulong max - 1
|
|
818
849
|
timestamp_max: 1n,
|
|
819
|
-
limit:
|
|
850
|
+
limit: BATCH_MAX,
|
|
820
851
|
flags: AccountFilterFlags.credits | AccountFilterFlags.debits,
|
|
821
852
|
}
|
|
822
853
|
assert.deepStrictEqual((await client.getAccountTransfers(filter)), [])
|
|
@@ -846,7 +877,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
846
877
|
code: 0,
|
|
847
878
|
timestamp_min: 0n,
|
|
848
879
|
timestamp_max: 0n,
|
|
849
|
-
limit:
|
|
880
|
+
limit: BATCH_MAX,
|
|
850
881
|
flags: AccountFilterFlags.none,
|
|
851
882
|
}
|
|
852
883
|
assert.deepStrictEqual((await client.getAccountTransfers(filter)), [])
|
|
@@ -861,7 +892,7 @@ test('can get account transfers', async (): Promise<void> => {
|
|
|
861
892
|
code: 0,
|
|
862
893
|
timestamp_min: 0n,
|
|
863
894
|
timestamp_max: 0n,
|
|
864
|
-
limit:
|
|
895
|
+
limit: BATCH_MAX,
|
|
865
896
|
flags: 0xFFFF,
|
|
866
897
|
}
|
|
867
898
|
assert.deepStrictEqual((await client.getAccountTransfers(filter)), [])
|
|
@@ -907,7 +938,7 @@ test('can query accounts', async (): Promise<void> => {
|
|
|
907
938
|
code: 999,
|
|
908
939
|
timestamp_min: 0n,
|
|
909
940
|
timestamp_max: 0n,
|
|
910
|
-
limit:
|
|
941
|
+
limit: BATCH_MAX,
|
|
911
942
|
flags: QueryFilterFlags.none,
|
|
912
943
|
}
|
|
913
944
|
var query: Account[] = await client.queryAccounts(filter)
|
|
@@ -938,7 +969,7 @@ test('can query accounts', async (): Promise<void> => {
|
|
|
938
969
|
code: 999,
|
|
939
970
|
timestamp_min: 0n,
|
|
940
971
|
timestamp_max: 0n,
|
|
941
|
-
limit:
|
|
972
|
+
limit: BATCH_MAX,
|
|
942
973
|
flags: QueryFilterFlags.reversed,
|
|
943
974
|
}
|
|
944
975
|
var query: Account[] = await client.queryAccounts(filter)
|
|
@@ -968,7 +999,7 @@ test('can query accounts', async (): Promise<void> => {
|
|
|
968
999
|
code: 999,
|
|
969
1000
|
timestamp_min: 0n,
|
|
970
1001
|
timestamp_max: 0n,
|
|
971
|
-
limit:
|
|
1002
|
+
limit: BATCH_MAX,
|
|
972
1003
|
flags: QueryFilterFlags.none,
|
|
973
1004
|
}
|
|
974
1005
|
var query: Account[] = await client.queryAccounts(filter)
|
|
@@ -1038,7 +1069,7 @@ test('can query accounts', async (): Promise<void> => {
|
|
|
1038
1069
|
code: 0,
|
|
1039
1070
|
timestamp_min: 0n,
|
|
1040
1071
|
timestamp_max: 0n,
|
|
1041
|
-
limit:
|
|
1072
|
+
limit: BATCH_MAX,
|
|
1042
1073
|
flags: QueryFilterFlags.none,
|
|
1043
1074
|
}
|
|
1044
1075
|
var query: Account[] = await client.queryAccounts(filter)
|
|
@@ -1102,7 +1133,7 @@ test('can query transfers', async (): Promise<void> => {
|
|
|
1102
1133
|
code: 999,
|
|
1103
1134
|
timestamp_min: 0n,
|
|
1104
1135
|
timestamp_max: 0n,
|
|
1105
|
-
limit:
|
|
1136
|
+
limit: BATCH_MAX,
|
|
1106
1137
|
flags: QueryFilterFlags.none,
|
|
1107
1138
|
}
|
|
1108
1139
|
var query: Transfer[] = await client.queryTransfers(filter)
|
|
@@ -1133,7 +1164,7 @@ test('can query transfers', async (): Promise<void> => {
|
|
|
1133
1164
|
code: 999,
|
|
1134
1165
|
timestamp_min: 0n,
|
|
1135
1166
|
timestamp_max: 0n,
|
|
1136
|
-
limit:
|
|
1167
|
+
limit: BATCH_MAX,
|
|
1137
1168
|
flags: QueryFilterFlags.reversed,
|
|
1138
1169
|
}
|
|
1139
1170
|
var query: Transfer[] = await client.queryTransfers(filter)
|
|
@@ -1163,7 +1194,7 @@ test('can query transfers', async (): Promise<void> => {
|
|
|
1163
1194
|
code: 999,
|
|
1164
1195
|
timestamp_min: 0n,
|
|
1165
1196
|
timestamp_max: 0n,
|
|
1166
|
-
limit:
|
|
1197
|
+
limit: BATCH_MAX,
|
|
1167
1198
|
flags: QueryFilterFlags.none,
|
|
1168
1199
|
}
|
|
1169
1200
|
var query: Transfer[] = await client.queryTransfers(filter)
|
|
@@ -1233,7 +1264,7 @@ test('can query transfers', async (): Promise<void> => {
|
|
|
1233
1264
|
code: 0,
|
|
1234
1265
|
timestamp_min: 0n,
|
|
1235
1266
|
timestamp_max: 0n,
|
|
1236
|
-
limit:
|
|
1267
|
+
limit: BATCH_MAX,
|
|
1237
1268
|
flags: QueryFilterFlags.none,
|
|
1238
1269
|
}
|
|
1239
1270
|
var query: Transfer[] = await client.queryTransfers(filter)
|
|
@@ -1251,7 +1282,7 @@ test('query with invalid filter', async (): Promise<void> => {
|
|
|
1251
1282
|
code: 0,
|
|
1252
1283
|
timestamp_min: (1n << 64n) - 1n, // ulong max value
|
|
1253
1284
|
timestamp_max: 0n,
|
|
1254
|
-
limit:
|
|
1285
|
+
limit: BATCH_MAX,
|
|
1255
1286
|
flags: QueryFilterFlags.none,
|
|
1256
1287
|
}
|
|
1257
1288
|
assert.deepStrictEqual((await client.queryAccounts(filter)), [])
|
|
@@ -1266,7 +1297,7 @@ test('query with invalid filter', async (): Promise<void> => {
|
|
|
1266
1297
|
code: 0,
|
|
1267
1298
|
timestamp_min: 0n,
|
|
1268
1299
|
timestamp_max: (1n << 64n) - 1n, // ulong max value,
|
|
1269
|
-
limit:
|
|
1300
|
+
limit: BATCH_MAX,
|
|
1270
1301
|
flags: QueryFilterFlags.none,
|
|
1271
1302
|
}
|
|
1272
1303
|
assert.deepStrictEqual((await client.queryAccounts(filter)), [])
|
|
@@ -1281,7 +1312,7 @@ test('query with invalid filter', async (): Promise<void> => {
|
|
|
1281
1312
|
code: 0,
|
|
1282
1313
|
timestamp_min: (1n << 64n) - 2n, // ulong max - 1
|
|
1283
1314
|
timestamp_max: 1n,
|
|
1284
|
-
limit:
|
|
1315
|
+
limit: BATCH_MAX,
|
|
1285
1316
|
flags: QueryFilterFlags.none,
|
|
1286
1317
|
}
|
|
1287
1318
|
assert.deepStrictEqual((await client.queryAccounts(filter)), [])
|