@@ -126,6 +126,84 @@ func TestMultiAssetJson(t *testing.T) {
126
126
}
127
127
}
128
128
129
+ func TestMultiAssetCompare (t * testing.T ) {
130
+ testDefs := []struct {
131
+ asset1 * MultiAsset [MultiAssetTypeOutput ]
132
+ asset2 * MultiAsset [MultiAssetTypeOutput ]
133
+ expectedResult bool
134
+ }{
135
+ {
136
+ asset1 : & MultiAsset [MultiAssetTypeOutput ]{
137
+ data : map [Blake2b224 ]map [cbor.ByteString ]MultiAssetTypeOutput {
138
+ NewBlake2b224 ([]byte ("abcd" )): {
139
+ cbor .NewByteString ([]byte ("cdef" )): 123 ,
140
+ },
141
+ },
142
+ },
143
+ asset2 : & MultiAsset [MultiAssetTypeOutput ]{
144
+ data : map [Blake2b224 ]map [cbor.ByteString ]MultiAssetTypeOutput {
145
+ NewBlake2b224 ([]byte ("abcd" )): {
146
+ cbor .NewByteString ([]byte ("cdef" )): 123 ,
147
+ },
148
+ },
149
+ },
150
+ expectedResult : true ,
151
+ },
152
+ {
153
+ asset1 : & MultiAsset [MultiAssetTypeOutput ]{
154
+ data : map [Blake2b224 ]map [cbor.ByteString ]MultiAssetTypeOutput {
155
+ NewBlake2b224 ([]byte ("abcd" )): {
156
+ cbor .NewByteString ([]byte ("cdef" )): 123 ,
157
+ },
158
+ },
159
+ },
160
+ asset2 : & MultiAsset [MultiAssetTypeOutput ]{
161
+ data : map [Blake2b224 ]map [cbor.ByteString ]MultiAssetTypeOutput {
162
+ NewBlake2b224 ([]byte ("abcd" )): {
163
+ cbor .NewByteString ([]byte ("cdef" )): 124 ,
164
+ },
165
+ },
166
+ },
167
+ expectedResult : false ,
168
+ },
169
+ {
170
+ asset1 : & MultiAsset [MultiAssetTypeOutput ]{
171
+ data : map [Blake2b224 ]map [cbor.ByteString ]MultiAssetTypeOutput {
172
+ NewBlake2b224 ([]byte ("abcd" )): {
173
+ cbor .NewByteString ([]byte ("cdef" )): 0 ,
174
+ },
175
+ },
176
+ },
177
+ asset2 : nil ,
178
+ expectedResult : true ,
179
+ },
180
+ {
181
+ asset1 : & MultiAsset [MultiAssetTypeOutput ]{
182
+ data : map [Blake2b224 ]map [cbor.ByteString ]MultiAssetTypeOutput {
183
+ NewBlake2b224 ([]byte ("abcd" )): {
184
+ cbor .NewByteString ([]byte ("cdef" )): 123 ,
185
+ },
186
+ },
187
+ },
188
+ asset2 : & MultiAsset [MultiAssetTypeOutput ]{
189
+ data : map [Blake2b224 ]map [cbor.ByteString ]MultiAssetTypeOutput {
190
+ NewBlake2b224 ([]byte ("abcd" )): {
191
+ cbor .NewByteString ([]byte ("cdef" )): 123 ,
192
+ cbor .NewByteString ([]byte ("efgh" )): 123 ,
193
+ },
194
+ },
195
+ },
196
+ expectedResult : false ,
197
+ },
198
+ }
199
+ for _ , testDef := range testDefs {
200
+ tmpResult := testDef .asset1 .Compare (testDef .asset2 )
201
+ if tmpResult != testDef .expectedResult {
202
+ t .Errorf ("did not get expected result: got %v, wanted %v" , tmpResult , testDef .expectedResult )
203
+ }
204
+ }
205
+ }
206
+
129
207
// Test the MarshalJSON method for Blake2b224 to ensure it properly converts to JSON.
130
208
func TestBlake2b224_MarshalJSON (t * testing.T ) {
131
209
// Example data to represent Blake2b224 hash
0 commit comments