@@ -102,10 +102,15 @@ func TestCreateTokenPoolFail(t *testing.T) {
102102 am , cancel := newTestAssets (t )
103103 defer cancel ()
104104
105+ mdi := am .database .(* databasemocks.Plugin )
105106 mdm := am .data .(* datamocks.Manager )
106107 mti := am .tokens ["magic-tokens" ].(* tokenmocks.Plugin )
107108 mdm .On ("VerifyNamespaceExists" , context .Background (), "ns1" ).Return (nil )
108- mti .On ("CreateTokenPool" , context .Background (), mock .Anything , mock .Anything ).Return ("" , fmt .Errorf ("pop" ))
109+ mdi .On ("UpsertTransaction" , context .Background (), mock .MatchedBy (func (tx * fftypes.Transaction ) bool {
110+ return tx .Subject .Type == fftypes .TransactionTypeTokenPool
111+ }), false ).Return (nil )
112+ mdi .On ("UpsertOperation" , mock .Anything , mock .Anything , false ).Return (nil )
113+ mti .On ("CreateTokenPool" , context .Background (), mock .Anything , mock .Anything ).Return (fmt .Errorf ("pop" ))
109114
110115 _ , err := am .CreateTokenPool (context .Background (), "ns1" , "magic-tokens" , & fftypes.TokenPool {}, false )
111116 assert .Regexp (t , "pop" , err )
@@ -117,15 +122,29 @@ func TestCreateTokenPoolTransactionFail(t *testing.T) {
117122
118123 mdi := am .database .(* databasemocks.Plugin )
119124 mdm := am .data .(* datamocks.Manager )
120- mti := am .tokens ["magic-tokens" ].(* tokenmocks.Plugin )
121125 mdm .On ("VerifyNamespaceExists" , context .Background (), "ns1" ).Return (nil )
122- mti .On ("CreateTokenPool" , context .Background (), mock .Anything , mock .Anything ).Return ("tx12345" , nil )
123126 mdi .On ("UpsertTransaction" , context .Background (), mock .Anything , false ).Return (fmt .Errorf ("pop" ))
124127
125128 _ , err := am .CreateTokenPool (context .Background (), "ns1" , "magic-tokens" , & fftypes.TokenPool {}, false )
126129 assert .Regexp (t , "pop" , err )
127130}
128131
132+ func TestCreateTokenPoolOperationFail (t * testing.T ) {
133+ am , cancel := newTestAssets (t )
134+ defer cancel ()
135+
136+ mdi := am .database .(* databasemocks.Plugin )
137+ mdm := am .data .(* datamocks.Manager )
138+ mdm .On ("VerifyNamespaceExists" , context .Background (), "ns1" ).Return (nil )
139+ mdi .On ("UpsertTransaction" , context .Background (), mock .MatchedBy (func (tx * fftypes.Transaction ) bool {
140+ return tx .Subject .Type == fftypes .TransactionTypeTokenPool
141+ }), false ).Return (nil )
142+ mdi .On ("UpsertOperation" , mock .Anything , mock .Anything , false ).Return (fmt .Errorf ("pop" ))
143+
144+ _ , err := am .CreateTokenPool (context .Background (), "ns1" , "magic-tokens" , & fftypes.TokenPool {}, false )
145+ assert .Regexp (t , "pop" , err )
146+ }
147+
129148func TestCreateTokenPoolSuccess (t * testing.T ) {
130149 am , cancel := newTestAssets (t )
131150 defer cancel ()
@@ -134,7 +153,7 @@ func TestCreateTokenPoolSuccess(t *testing.T) {
134153 mdm := am .data .(* datamocks.Manager )
135154 mti := am .tokens ["magic-tokens" ].(* tokenmocks.Plugin )
136155 mdm .On ("VerifyNamespaceExists" , context .Background (), "ns1" ).Return (nil )
137- mti .On ("CreateTokenPool" , context .Background (), mock .Anything , mock .Anything ).Return ("tx12345" , nil )
156+ mti .On ("CreateTokenPool" , context .Background (), mock .Anything , mock .Anything ).Return (nil )
138157 mdi .On ("UpsertTransaction" , context .Background (), mock .MatchedBy (func (tx * fftypes.Transaction ) bool {
139158 return tx .Subject .Type == fftypes .TransactionTypeTokenPool
140159 }), false ).Return (nil )
@@ -157,13 +176,11 @@ func TestCreateTokenPoolConfirm(t *testing.T) {
157176 mdm .On ("VerifyNamespaceExists" , context .Background (), "ns1" ).Return (nil ).Times (2 )
158177 mti .On ("CreateTokenPool" , context .Background (), mock .Anything , mock .MatchedBy (func (pool * fftypes.TokenPool ) bool {
159178 return pool .ID == requestID
160- })).Return ("tx12345" , nil ).Times (1 )
179+ })).Return (nil ).Times (1 )
161180 mdi .On ("UpsertTransaction" , context .Background (), mock .MatchedBy (func (tx * fftypes.Transaction ) bool {
162181 return tx .Subject .Type == fftypes .TransactionTypeTokenPool
163182 }), false ).Return (nil )
164- mdi .On ("UpsertOperation" , mock .Anything , mock .MatchedBy (func (op * fftypes.Operation ) bool {
165- return op .BackendID == "tx12345"
166- }), false ).Return (nil ).Times (1 )
183+ mdi .On ("UpsertOperation" , mock .Anything , mock .Anything , false ).Return (nil ).Times (1 )
167184 msa .On ("SendConfirmTokenPool" , context .Background (), "ns1" , mock .Anything ).
168185 Run (func (args mock.Arguments ) {
169186 send := args [2 ].(syncasync.RequestSender )
0 commit comments