@@ -650,6 +650,130 @@ func TestClient_GetSystemTransactionResult(t *testing.T) {
650650 }))
651651}
652652
653+ func TestClient_GetSystemTransaction_WithID_SetsId (t * testing.T ) {
654+ txs := test .TransactionGenerator ()
655+ ids := test .IdentifierGenerator ()
656+
657+ t .Run ("WithID sets request Id" , clientTest (func (t * testing.T , ctx context.Context , rpc * mocks.MockRPCClient , c * BaseClient ) {
658+ blockID := ids .New ()
659+ systemTxID := ids .New ()
660+ expectedTx := txs .New ()
661+
662+ txMsg , err := convert .TransactionToMessage (* expectedTx )
663+ require .NoError (t , err )
664+
665+ response := & access.TransactionResponse {Transaction : txMsg }
666+
667+ rpc .
668+ On ("GetSystemTransaction" , ctx , mock .Anything ).
669+ Return (response , nil ).
670+ Run (func (args mock.Arguments ) {
671+ req , ok := args .Get (1 ).(* access.GetSystemTransactionRequest )
672+ require .True (t , ok )
673+ assert .Equal (t , blockID .Bytes (), req .GetBlockId ())
674+ assert .Equal (t , systemTxID .Bytes (), req .GetId ())
675+ })
676+
677+ tx , err := c .GetSystemTransactionWithID (ctx , blockID , systemTxID )
678+ require .NoError (t , err )
679+ assert .Equal (t , expectedTx , tx )
680+ }))
681+ }
682+
683+ func TestClient_GetSystemTransaction_WithEmptyID_OmitsId (t * testing.T ) {
684+ txs := test .TransactionGenerator ()
685+ ids := test .IdentifierGenerator ()
686+
687+ t .Run ("EmptyID omits request Id" , clientTest (func (t * testing.T , ctx context.Context , rpc * mocks.MockRPCClient , c * BaseClient ) {
688+ blockID := ids .New ()
689+ expectedTx := txs .New ()
690+
691+ txMsg , err := convert .TransactionToMessage (* expectedTx )
692+ require .NoError (t , err )
693+
694+ response := & access.TransactionResponse {Transaction : txMsg }
695+
696+ rpc .
697+ On ("GetSystemTransaction" , ctx , mock .Anything ).
698+ Return (response , nil ).
699+ Run (func (args mock.Arguments ) {
700+ req , ok := args .Get (1 ).(* access.GetSystemTransactionRequest )
701+ require .True (t , ok )
702+ assert .Equal (t , blockID .Bytes (), req .GetBlockId ())
703+ assert .Len (t , req .GetId (), 0 )
704+ })
705+
706+ tx , err := c .GetSystemTransactionWithID (ctx , blockID , flow .EmptyID )
707+ require .NoError (t , err )
708+ assert .Equal (t , expectedTx , tx )
709+ }))
710+ }
711+
712+ func TestClient_GetSystemTransactionResult_WithID_SetsId (t * testing.T ) {
713+ ids := test .IdentifierGenerator ()
714+
715+ t .Run ("WithID sets request Id" , clientTest (func (t * testing.T , ctx context.Context , rpc * mocks.MockRPCClient , c * BaseClient ) {
716+ blockID := ids .New ()
717+ systemTxID := ids .New ()
718+
719+ // Build a minimal result
720+ results := test .TransactionResultGenerator (flow .EventEncodingVersionCCF )
721+ expectedResult := results .New ()
722+ response , _ := convert .TransactionResultToMessage (expectedResult , flow .EventEncodingVersionCCF )
723+
724+ rpc .
725+ On ("GetSystemTransactionResult" , ctx , mock .Anything ).
726+ Return (response , nil ).
727+ Run (func (args mock.Arguments ) {
728+ req , ok := args .Get (1 ).(* access.GetSystemTransactionResultRequest )
729+ require .True (t , ok )
730+ assert .Equal (t , blockID .Bytes (), req .GetBlockId ())
731+ assert .Equal (t , systemTxID .Bytes (), req .GetId ())
732+ assert .Equal (t , entities .EventEncodingVersion_CCF_V0 , req .GetEventEncodingVersion ())
733+ })
734+
735+ result , err := c .GetSystemTransactionResultWithID (ctx , blockID , systemTxID )
736+ require .NoError (t , err )
737+
738+ // force type evaluation for equality
739+ for _ , event := range result .Events {
740+ _ = event .Value .Type ().ID ()
741+ }
742+ assert .Equal (t , expectedResult , * result )
743+ }))
744+ }
745+
746+ func TestClient_GetSystemTransactionResult_WithEmptyID_OmitsId (t * testing.T ) {
747+ ids := test .IdentifierGenerator ()
748+
749+ t .Run ("EmptyID omits request Id" , clientTest (func (t * testing.T , ctx context.Context , rpc * mocks.MockRPCClient , c * BaseClient ) {
750+ blockID := ids .New ()
751+
752+ results := test .TransactionResultGenerator (flow .EventEncodingVersionCCF )
753+ expectedResult := results .New ()
754+ response , _ := convert .TransactionResultToMessage (expectedResult , flow .EventEncodingVersionCCF )
755+
756+ rpc .
757+ On ("GetSystemTransactionResult" , ctx , mock .Anything ).
758+ Return (response , nil ).
759+ Run (func (args mock.Arguments ) {
760+ req , ok := args .Get (1 ).(* access.GetSystemTransactionResultRequest )
761+ require .True (t , ok )
762+ assert .Equal (t , blockID .Bytes (), req .GetBlockId ())
763+ assert .Len (t , req .GetId (), 0 )
764+ assert .Equal (t , entities .EventEncodingVersion_CCF_V0 , req .GetEventEncodingVersion ())
765+ })
766+
767+ result , err := c .GetSystemTransactionResultWithID (ctx , blockID , flow .EmptyID )
768+ require .NoError (t , err )
769+
770+ for _ , event := range result .Events {
771+ _ = event .Value .Type ().ID ()
772+ }
773+ assert .Equal (t , expectedResult , * result )
774+ }))
775+ }
776+
653777func TestClient_GetTransactionResult (t * testing.T ) {
654778 ids := test .IdentifierGenerator ()
655779
0 commit comments