@ -1,6 +1,7 @@
/ / The public note of spec § 24.1 against Go: test / vectors / open_notes . json ,
/ / which tool / open_go_vectors . go writes with extension . CheckNote , Note ,
/ / Header . UnusableNote and extension . Standard of the reference .
/ / Header . UnusableNote and extension . Standard of the reference ; and
/ / testdata / vectors / note . json , the cases of the list of v0 . 11 of spec § 64.
@ TestOn ( ' vm ' )
library ;
@ -28,6 +29,44 @@ void main() {
) ;
} ) ;
test ( ' note.json: the data of each note and the result of its rules ' , ( ) {
final f = readJson ( ' testdata/vectors/note.json ' ) ;
expect ( f [ ' spec ' ] , specVersion ) ;
final notes = ( f [ ' notes ' ] ! as List ) . cast < Json > ( ) ;
expect ( notes , hasLength ( 16 ) ) ;
expect ( notes . where ( ( c ) = > c [ ' result ' ] = = ' ok ' ) , hasLength ( 4 ) ) ;
for ( final c in notes ) {
final data = fromHex ( c [ ' data ' ] ! as String ) ;
final reason = c [ ' name ' ] as String ? ;
/ / detail is the text of the rule , without the code .
final want = c [ ' result ' ] = = ' ok '
? [ ' ok ' , ' ' ]
: [ c [ ' result ' ] , ' ${ c [ ' detail ' ] } : ${ c [ ' result ' ] } ' ] ;
String ? text ;
expect ( outcomeOf ( ( ) = > text = checkNoteData ( data ) ) , want , reason: reason ) ;
/ / A reader shows the note only when it is ok , and otherwise treats it
/ / as unusable , never the capsule ( spec § 54 ) .
final exts = [ Extension ( noteExtensionId , 1 , data . isEmpty ? null : data ) ] ;
expect (
[ publicNote ( exts ) , unusableNote ( exts ) ] ,
c [ ' result ' ] = = ' ok ' ? [ text , false ] : [ null , true ] ,
reason: reason ,
) ;
expect (
[
for ( final u in checkNoncritical (
exts ,
const StandardExtensions ( ) ,
ExtensionObject . publicHeader ,
) )
u . error . code . code ,
] ,
c [ ' result ' ] = = ' ok ' ? isEmpty : [ c [ ' result ' ] ] ,
reason: reason ,
) ;
}
} ) ;
test ( ' the note of a header, as PublicNote and UnusableNote of Go ' , ( ) {
final r = jsonDecode (
File ( ' testdata/fixtures/time_only_extensions.json ' ) . readAsStringSync ( ) ,