@@ -17,6 +17,7 @@ package mary
17
17
import (
18
18
"encoding/hex"
19
19
"reflect"
20
+ "regexp"
20
21
"testing"
21
22
22
23
"github.com/blinklabs-io/gouroboros/cbor"
@@ -115,3 +116,34 @@ func TestMaryTransactionOutputValueEncodeDecode(t *testing.T) {
115
116
}
116
117
}
117
118
}
119
+
120
+ func TestMaryTransactionOutputString (t * testing.T ) {
121
+ addr , _ := common .NewAddress ("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd" )
122
+ ma := common.NewMultiAsset [common.MultiAssetTypeOutput ](
123
+ map [common.Blake2b224 ]map [cbor.ByteString ]uint64 {
124
+ common .NewBlake2b224 (make ([]byte , 28 )): {cbor .NewByteString ([]byte ("token" )): 2 },
125
+ },
126
+ )
127
+ out := MaryTransactionOutput {
128
+ OutputAddress : addr ,
129
+ OutputAmount : MaryTransactionOutputValue {Amount : 456 , Assets : & ma },
130
+ }
131
+ s := out .String ()
132
+ re := regexp .MustCompile (`^\(MaryTransactionOutput address=addr1[0-9a-z]+ amount=456 assets=\.\.\.\)$` )
133
+ if ! re .MatchString (s ) {
134
+ t .Fatalf ("unexpected string: %s" , s )
135
+ }
136
+ }
137
+
138
+ func TestMaryOutputTooBigErrorFormatting (t * testing.T ) {
139
+ addr , _ := common .NewAddress ("addr1qytna5k2fq9ler0fuk45j7zfwv7t2zwhp777nvdjqqfr5tz8ztpwnk8zq5ngetcz5k5mckgkajnygtsra9aej2h3ek5seupmvd" )
140
+ out := & MaryTransactionOutput {
141
+ OutputAddress : addr ,
142
+ OutputAmount : MaryTransactionOutputValue {Amount : 456 },
143
+ }
144
+ errStr := OutputTooBigUtxoError {Outputs : []common.TransactionOutput {out }}.Error ()
145
+ re := regexp .MustCompile (`^output value too large: \(MaryTransactionOutput address=addr1[0-9a-z]+ amount=456\)$` )
146
+ if ! re .MatchString (errStr ) {
147
+ t .Fatalf ("unexpected error: %s" , errStr )
148
+ }
149
+ }
0 commit comments