@@ -475,6 +475,9 @@ func testProg(t testing.TB, source string, ver uint64, expected ...expect) *OpSt
475475 require .NoError (t , err )
476476 require .Equal (t , ops .Program , ops2 .Program )
477477 } else {
478+ if err == nil {
479+ t .Log (program )
480+ }
478481 require .Error (t , err )
479482 errors := ops .Errors
480483 for _ , exp := range expected {
@@ -507,6 +510,7 @@ func testProg(t testing.TB, source string, ver uint64, expected ...expect) *OpSt
507510}
508511
509512func testLine (t * testing.T , line string , ver uint64 , expected string ) {
513+ t .Helper ()
510514 // By embedding the source line between two other lines, the
511515 // test for the correct line number in the error is more
512516 // meaningful.
@@ -517,6 +521,7 @@ func testLine(t *testing.T, line string, ver uint64, expected string) {
517521 }
518522 testProg (t , source , ver , expect {2 , expected })
519523}
524+
520525func TestAssembleTxna (t * testing.T ) {
521526 partitiontest .PartitionTest (t )
522527
@@ -661,6 +666,7 @@ func TestAssembleBytes(t *testing.T) {
661666 variations := []string {
662667 "byte b32 MFRGGZDFMY" ,
663668 "byte base32 MFRGGZDFMY" ,
669+ "byte base32 MFRGGZDFMY" ,
664670 "byte base32(MFRGGZDFMY)" ,
665671 "byte b32(MFRGGZDFMY)" ,
666672 "byte b32 MFRGGZDFMY======" ,
@@ -679,6 +685,11 @@ func TestAssembleBytes(t *testing.T) {
679685 expectedDefaultConsts := "0126010661626364656628"
680686 expectedOptimizedConsts := "018006616263646566"
681687
688+ bad := [][]string {
689+ {"byte" , "...operation needs byte literal argument" },
690+ {`byte "john" "doe"` , "...operation with extraneous argument" },
691+ }
692+
682693 for v := uint64 (1 ); v <= AssemblerMaxVersion ; v ++ {
683694 t .Run (fmt .Sprintf ("v=%d" , v ), func (t * testing.T ) {
684695 expected := expectedDefaultConsts
@@ -690,8 +701,19 @@ func TestAssembleBytes(t *testing.T) {
690701 ops := testProg (t , vi , v )
691702 s := hex .EncodeToString (ops .Program )
692703 require .Equal (t , mutateProgVersion (v , expected ), s )
704+ // pushbytes should take the same input
705+ if v >= 3 {
706+ testProg (t , strings .Replace (vi , "byte" , "pushbytes" , 1 ), v )
707+ }
693708 }
694709
710+ for _ , b := range bad {
711+ testProg (t , b [0 ], v , expect {1 , b [1 ]})
712+ // pushbytes should produce the same errors
713+ if v >= 3 {
714+ testProg (t , strings .Replace (b [0 ], "byte" , "pushbytes" , 1 ), v , expect {1 , b [1 ]})
715+ }
716+ }
695717 })
696718 }
697719}
@@ -1448,7 +1470,7 @@ func TestConstantArgs(t *testing.T) {
14481470 }
14491471 for v := uint64 (3 ); v <= AssemblerMaxVersion ; v ++ {
14501472 testProg (t , "pushint" , v , expect {1 , "pushint needs one argument" })
1451- testProg (t , "pushbytes" , v , expect {1 , "pushbytes needs one argument" })
1473+ testProg (t , "pushbytes" , v , expect {1 , "pushbytes operation needs byte literal argument" })
14521474 }
14531475
14541476}
0 commit comments