summaryrefslogtreecommitdiff
path: root/test/storage.test
blob: 10f5d2c3ec522dffdb614e1ca0c44c7787615eb6 (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
test:
	spawn on node1 as p1

	# 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/