@@ -28,72 +28,73 @@ func RunDATestSuite(t *testing.T, d da.DA) {
28
28
})
29
29
}
30
30
31
- // TODO(tzdybal): how to get rid of those aliases?
32
-
33
- // Blob is a type alias
34
- type Blob = da.Blob
35
-
36
- // ID is a type alias
37
- type ID = da.ID
38
-
39
31
// BasicDATest tests round trip of messages to DA and back.
40
- func BasicDATest (t * testing.T , da da.DA ) {
32
+ func BasicDATest (t * testing.T , d da.DA ) {
41
33
msg1 := []byte ("message 1" )
42
34
msg2 := []byte ("message 2" )
43
35
44
36
ctx := context .TODO ()
45
- id1 , proof1 , err := da .Submit (ctx , []Blob {msg1 }, - 1 )
37
+ id1 , proof1 , err := d .Submit (ctx , []da.Blob {msg1 }, & da.SubmitOptions {
38
+ GasPrice : 0 ,
39
+ Namespace : []byte {9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 },
40
+ })
46
41
assert .NoError (t , err )
47
42
assert .NotEmpty (t , id1 )
48
43
assert .NotEmpty (t , proof1 )
49
44
50
- id2 , proof2 , err := da .Submit (ctx , []Blob {msg2 }, - 1 )
45
+ id2 , proof2 , err := d .Submit (ctx , []da.Blob {msg2 }, & da.SubmitOptions {
46
+ GasPrice : 0 ,
47
+ Namespace : []byte {9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 },
48
+ })
51
49
assert .NoError (t , err )
52
50
assert .NotEmpty (t , id2 )
53
51
assert .NotEmpty (t , proof2 )
54
52
55
- id3 , proof3 , err := da .Submit (ctx , []Blob {msg1 }, - 1 )
53
+ id3 , proof3 , err := d .Submit (ctx , []da.Blob {msg1 }, & da.SubmitOptions {
54
+ GasPrice : 0 ,
55
+ Namespace : []byte {9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 },
56
+ })
56
57
assert .NoError (t , err )
57
58
assert .NotEmpty (t , id3 )
58
59
assert .NotEmpty (t , proof3 )
59
60
60
61
assert .NotEqual (t , id1 , id2 )
61
62
assert .NotEqual (t , id1 , id3 )
62
63
63
- ret , err := da .Get (ctx , id1 )
64
+ ret , err := d .Get (ctx , id1 )
64
65
assert .NoError (t , err )
65
- assert .Equal (t , []Blob {msg1 }, ret )
66
+ assert .Equal (t , []da. Blob {msg1 }, ret )
66
67
67
- commitment1 , err := da .Commit (ctx , []Blob {msg1 })
68
+ commitment1 , err := d .Commit (ctx , []da. Blob {msg1 })
68
69
assert .NoError (t , err )
69
70
assert .NotEmpty (t , commitment1 )
70
71
71
- commitment2 , err := da .Commit (ctx , []Blob {msg2 })
72
+ commitment2 , err := d .Commit (ctx , []da. Blob {msg2 })
72
73
assert .NoError (t , err )
73
74
assert .NotEmpty (t , commitment2 )
74
75
75
- oks , err := da .Validate (ctx , id1 , proof1 )
76
+ oks , err := d .Validate (ctx , id1 , proof1 )
76
77
assert .NoError (t , err )
77
78
assert .NotEmpty (t , oks )
78
79
for _ , ok := range oks {
79
80
assert .True (t , ok )
80
81
}
81
82
82
- oks , err = da .Validate (ctx , id2 , proof2 )
83
+ oks , err = d .Validate (ctx , id2 , proof2 )
83
84
assert .NoError (t , err )
84
85
assert .NotEmpty (t , oks )
85
86
for _ , ok := range oks {
86
87
assert .True (t , ok )
87
88
}
88
89
89
- oks , err = da .Validate (ctx , id1 , proof2 )
90
+ oks , err = d .Validate (ctx , id1 , proof2 )
90
91
assert .NoError (t , err )
91
92
assert .NotEmpty (t , oks )
92
93
for _ , ok := range oks {
93
94
assert .False (t , ok )
94
95
}
95
96
96
- oks , err = da .Validate (ctx , id2 , proof1 )
97
+ oks , err = d .Validate (ctx , id2 , proof1 )
97
98
assert .NoError (t , err )
98
99
assert .NotEmpty (t , oks )
99
100
for _ , ok := range oks {
@@ -102,19 +103,22 @@ func BasicDATest(t *testing.T, da da.DA) {
102
103
}
103
104
104
105
// CheckErrors ensures that errors are handled properly by DA.
105
- func CheckErrors (t * testing.T , da da.DA ) {
106
+ func CheckErrors (t * testing.T , d da.DA ) {
106
107
ctx := context .TODO ()
107
- blob , err := da .Get (ctx , []ID {[]byte ("invalid" )})
108
+ blob , err := d .Get (ctx , []da. ID {[]byte ("invalid" )})
108
109
assert .Error (t , err )
109
110
assert .Empty (t , blob )
110
111
}
111
112
112
113
// GetIDsTest tests iteration over DA
113
- func GetIDsTest (t * testing.T , da da.DA ) {
114
+ func GetIDsTest (t * testing.T , d da.DA ) {
114
115
msgs := [][]byte {[]byte ("msg1" ), []byte ("msg2" ), []byte ("msg3" )}
115
116
116
117
ctx := context .TODO ()
117
- ids , proofs , err := da .Submit (ctx , msgs , - 1 )
118
+ ids , proofs , err := d .Submit (ctx , msgs , & da.SubmitOptions {
119
+ GasPrice : 0 ,
120
+ Namespace : []byte {9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 },
121
+ })
118
122
assert .NoError (t , err )
119
123
assert .Len (t , ids , len (msgs ))
120
124
assert .Len (t , proofs , len (msgs ))
@@ -126,12 +130,12 @@ func GetIDsTest(t *testing.T, da da.DA) {
126
130
// As we're the only user, we don't need to handle external data (that could be submitted in real world).
127
131
// There is no notion of height, so we need to scan the DA to get test data back.
128
132
for i := uint64 (1 ); ! found && ! time .Now ().After (end ); i ++ {
129
- ret , err := da .GetIDs (ctx , i )
133
+ ret , err := d .GetIDs (ctx , i )
130
134
if err != nil {
131
135
t .Error ("failed to get IDs:" , err )
132
136
}
133
137
if len (ret ) > 0 {
134
- blobs , err := da .Get (ctx , ret )
138
+ blobs , err := d .Get (ctx , ret )
135
139
assert .NoError (t , err )
136
140
137
141
// Submit ensures atomicity of batch, so it makes sense to compare actual blobs (bodies) only when lengths
@@ -151,7 +155,7 @@ func GetIDsTest(t *testing.T, da da.DA) {
151
155
}
152
156
153
157
// ConcurrentReadWriteTest tests the use of mutex lock in DummyDA by calling separate methods that use `d.data` and making sure there's no race conditions
154
- func ConcurrentReadWriteTest (t * testing.T , da da.DA ) {
158
+ func ConcurrentReadWriteTest (t * testing.T , d da.DA ) {
155
159
var wg sync.WaitGroup
156
160
wg .Add (2 )
157
161
@@ -160,15 +164,18 @@ func ConcurrentReadWriteTest(t *testing.T, da da.DA) {
160
164
go func () {
161
165
defer wg .Done ()
162
166
for i := uint64 (1 ); i <= 100 ; i ++ {
163
- _ , err := da .GetIDs (ctx , i )
167
+ _ , err := d .GetIDs (ctx , i )
164
168
assert .NoError (t , err )
165
169
}
166
170
}()
167
171
168
172
go func () {
169
173
defer wg .Done ()
170
174
for i := uint64 (1 ); i <= 100 ; i ++ {
171
- _ , _ , err := da .Submit (ctx , [][]byte {[]byte ("test" )}, - 1 )
175
+ _ , _ , err := d .Submit (ctx , [][]byte {[]byte ("test" )}, & da.SubmitOptions {
176
+ GasPrice : 0 ,
177
+ Namespace : []byte {9 , 8 , 7 , 6 , 5 , 4 , 3 , 2 , 1 , 0 },
178
+ })
172
179
assert .NoError (t , err )
173
180
}
174
181
}()
0 commit comments