@@ -40,6 +40,37 @@ test('vatstore', async t => {
40
40
send ( 'get' , 'zot' ) ;
41
41
await c . run ( ) ;
42
42
43
+ for ( const k of hostStorage . kvStore . getKeys ( '' , '' ) ) {
44
+ if ( k . endsWith ( '.foo' ) ) {
45
+ t . is ( k , 'v1.vs.vvs.foo' ) ;
46
+ }
47
+ }
48
+
49
+ send ( 'store' , 'x.1' , 'one' ) ;
50
+ send ( 'store' , 'x.2' , 'two' ) ;
51
+ send ( 'store' , 'x.3' , 'three' ) ;
52
+ send ( 'store' , 'x.a' , 'four' ) ;
53
+ send ( 'store' , 'x.qrz' , 'five' ) ;
54
+ send ( 'store' , 'xxx' , 'not this' ) ;
55
+ send ( 'store' , 'y.1' , 'oney' ) ;
56
+ send ( 'store' , 'y.2' , 'twoy' ) ;
57
+ send ( 'store' , 'y.3' , 'threey' ) ;
58
+ send ( 'store' , 'y.a' , 'foury' ) ;
59
+ send ( 'store' , 'y.b' , 'fivey' ) ;
60
+ send ( 'store' , 'y.c' , 'sixy' ) ;
61
+ send ( 'store' , 'y.d' , 'seveny' ) ;
62
+ send ( 'store' , 'yyy' , 'not thisy' ) ;
63
+ // check that we hit all the 'x.' keys
64
+ send ( 'scan' , 'x.' ) ;
65
+ // check that this works even if the iteration is interrupted
66
+ send ( 'scan' , 'x.' , 3 ) ;
67
+ // check that interleaved iterations don't interfere
68
+ send ( 'scanInterleaved' , 'x.' , 'y.' ) ;
69
+ // check for a successful empty iteration if there's no match
70
+ send ( 'scan' , 'z.' ) ;
71
+ // exercise various calls with malformed parameters
72
+ send ( 'apiAbuse' , 'x.' ) ;
73
+ await c . run ( ) ;
43
74
t . deepEqual ( c . dump ( ) . log , [
44
75
'get zot -> <undefined>' ,
45
76
'store zot <- "first zot"' ,
@@ -51,10 +82,52 @@ test('vatstore', async t => {
51
82
'delete zot' ,
52
83
'get foo -> "first foo"' ,
53
84
'get zot -> <undefined>' ,
85
+ 'store x.1 <- "one"' ,
86
+ 'store x.2 <- "two"' ,
87
+ 'store x.3 <- "three"' ,
88
+ 'store x.a <- "four"' ,
89
+ 'store x.qrz <- "five"' ,
90
+ 'store xxx <- "not this"' ,
91
+ 'store y.1 <- "oney"' ,
92
+ 'store y.2 <- "twoy"' ,
93
+ 'store y.3 <- "threey"' ,
94
+ 'store y.a <- "foury"' ,
95
+ 'store y.b <- "fivey"' ,
96
+ 'store y.c <- "sixy"' ,
97
+ 'store y.d <- "seveny"' ,
98
+ 'store yyy <- "not thisy"' ,
99
+ 'scan x.:' ,
100
+ ' x.1 -> one' ,
101
+ ' x.2 -> two' ,
102
+ ' x.3 -> three' ,
103
+ ' x.a -> four' ,
104
+ ' x.qrz -> five' ,
105
+ 'scan x. 3:' ,
106
+ ' x.1 -> one' ,
107
+ ' x.2 -> two' ,
108
+ ' x.3 -> three' ,
109
+ ' interrupting...' ,
110
+ ' x.a -> four' ,
111
+ ' x.qrz -> five' ,
112
+ 'scanInterleaved x. y.:' ,
113
+ ' 1: x.1 -> one' ,
114
+ ' 2: y.1 -> oney' ,
115
+ ' 1: x.2 -> two' ,
116
+ ' 2: y.2 -> twoy' ,
117
+ ' 1: x.3 -> three' ,
118
+ ' 2: y.3 -> threey' ,
119
+ ' 1: x.a -> four' ,
120
+ ' 2: y.a -> foury' ,
121
+ ' 1: x.qrz -> five' ,
122
+ ' 2: y.b -> fivey' ,
123
+ ' 2: y.c -> sixy' ,
124
+ ' 2: y.d -> seveny' ,
125
+ 'scan z.:' ,
126
+ 'apiAbuse x.: use prefix as prior key (should work)' ,
127
+ ' x.1 -> one' ,
128
+ 'apiAbuse x.: use out of range prior key aaax.' ,
129
+ ' getAfter(x., aaax.) threw Error: priorKey must start with keyPrefix' ,
130
+ 'apiAbuse x.: use invalid key prefix' ,
131
+ ' getAfter("ab@%%$#", "") threw Error: invalid vatstore key' ,
54
132
] ) ;
55
- for ( const k of hostStorage . kvStore . getKeys ( '' , '' ) ) {
56
- if ( k . endsWith ( '.foo' ) ) {
57
- t . is ( k , 'v1.vs.vvs.foo' ) ;
58
- }
59
- }
60
133
} ) ;
0 commit comments