summaryrefslogtreecommitdiff
path: root/storage.test
blob: 17859cc4fe9ef1c193b0373bd7ce1aac9776800b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
test:
	spawn as p1

	# Root finding
	###############

	# Diamond history
	send to p1:
		"store rec"
		"text:t First root"
		""
	expect from p1:
		/store-done (blake2#[0-9a-f]*)/ capture r1
	guard r1 == "blake2#c4a8c69fbc8398acf76a2ec1e5a191f339c4d03c3eb425af19d6d7d5efac6b8e"

	send to p1:
		"store rec"
		"PREV:r $r1"
		""
	expect from p1:
		/store-done (blake2#[0-9a-f]*)/ capture r2

	send to p1:
		"store rec"
		"text:t Second branch"
		"PREV:r $r1"
		""
	expect from p1:
		/store-done (blake2#[0-9a-f]*)/ capture r3

	send to p1:
		"store rec"
		"PREV:r $r2"
		"PREV:r $r3"
		""
	expect from p1:
		/store-done (blake2#[0-9a-f]*)/ capture r4

	send to p1 "stored-generation $r1"
	expect from p1 /stored-generation $r1 0/

	send to p1 "stored-generation $r2"
	expect from p1 /stored-generation $r2 1/

	send to p1 "stored-generation $r3"
	expect from p1 /stored-generation $r3 1/

	send to p1 "stored-generation $r4"
	expect from p1 /stored-generation $r4 2/

	send to p1 "stored-roots $r1"
	expect from p1 /stored-roots $r1 $r1/

	send to p1 "stored-roots $r2"
	expect from p1 /stored-roots $r2 $r1/

	send to p1 "stored-roots $r3"
	expect from p1 /stored-roots $r3 $r1/

	send to p1 "stored-roots $r4"
	expect from p1 /stored-roots $r4 $r1/

	# Attach second root
	send to p1:
		"store rec"
		"text:t Second root"
		""
	expect from p1:
		/store-done (blake2#[0-9a-f]*)/ capture r2_1

	send to p1:
		"store rec"
		"PREV:r $r2_1"
		""
	expect from p1:
		/store-done (blake2#[0-9a-f]*)/ capture r2_2

	send to p1:
		"store rec"
		"PREV:r $r2_2"
		"PREV:r $r4"
		""
	expect from p1:
		/store-done (blake2#[0-9a-f]*)/ capture r2_3

	send to p1 "stored-generation $r2_3"
	expect from p1 /stored-generation $r2_3 3/

	send to p1 "stored-generation $r2_2"
	expect from p1 /stored-generation $r2_2 1/

	send to p1 "stored-roots $r2_3"
	expect from p1 /stored-roots $r2_3 $r2_1 $r1/

	send to p1 "stored-roots $r2_2"
	expect from p1 /stored-roots $r2_2 $r2_1/


	# Set
	#####

	send to p1 "stored-set-add $r1"
	expect from p1 /stored-set-add (blake2#[0-9a-f]*)/ capture s1
	send to p1 "stored-set-add $r2 $s1"
	expect from p1 /stored-set-add (blake2#[0-9a-f]*)/ capture s2
	send to p1 "stored-set-add $r3 $s2"
	expect from p1 /stored-set-add (blake2#[0-9a-f]*)/ capture s3
	send to p1 "stored-set-add $r4 $s3"
	expect from p1 /stored-set-add (blake2#[0-9a-f]*)/ capture s4

	send to p1 "stored-set-list $s1"
	expect from p1:
		/stored-set-item $r1/
		/stored-set-(.*)/ capture done1
	guard done1 == "done"

	send to p1 "stored-set-list $s2"
	expect from p1:
		/stored-set-item $r2/
		/stored-set-(.*)/ capture done2
	guard done2 == "done"

	send to p1 "stored-set-list $s3"
	expect from p1:
		/stored-set-item $r2 $r3/
		/stored-set-(.*)/ capture done3
	guard done3 == "done"

	send to p1 "stored-set-list $s4"
	expect from p1:
		/stored-set-item $r4/
		/stored-set-(.*)/ capture done4
	guard done4 == "done"


	send to p1 "stored-set-add $r2_2 $s4"
	expect from p1 /stored-set-add (blake2#[0-9a-f]*)/ capture s5
	send to p1 "stored-set-add $r2_3 $s5"
	expect from p1 /stored-set-add (blake2#[0-9a-f]*)/ capture s6

	send to p1 "stored-set-list $s5"
	expect from p1:
		/stored-set-item $r4/
		/stored-set-item $r2_2/
		/stored-set-(.*)/ capture done5
	guard done5 == "done"

	send to p1 "stored-set-list $s6"
	expect from p1:
		/stored-set-item $r2_3/
		/stored-set-(.*)/ capture done6
	guard done6 == "done"