@@ -17,6 +17,7 @@ import Cardano.Transaction.Builder
17
17
, WrongOutputType
18
18
)
19
19
, buildTransaction
20
+ , modifyTransaction
20
21
)
21
22
import Cardano.Transaction.Edit (editTransaction , editTransactionSafe )
22
23
import Cardano.Types
@@ -81,7 +82,7 @@ suite = do
81
82
editorTests :: TestPlanM (Aff Unit ) Unit
82
83
editorTests = group " Cardano.Transaction.Edit" do
83
84
let
84
- oneInput = mainnetTransaction
85
+ oneInput = anyNetworkTx
85
86
# _witnessSet <<< _redeemers .~
86
87
[ Redeemer
87
88
{ index: BigNum .zero
@@ -97,7 +98,7 @@ editorTests = group "Cardano.Transaction.Edit" do
97
98
editTransaction identity oneInput `shouldEqual` oneInput
98
99
test " attach one input to the end" do
99
100
let
100
- tx' = mainnetTransaction
101
+ tx' = anyNetworkTx
101
102
# _witnessSet <<< _redeemers .~
102
103
[ Redeemer
103
104
{ index: BigNum .zero
@@ -112,7 +113,7 @@ editorTests = group "Cardano.Transaction.Edit" do
112
113
`shouldEqual` tx'
113
114
test " remove two inputs, before and after" do
114
115
let
115
- tx = mainnetTransaction
116
+ tx = anyNetworkTx
116
117
# _witnessSet <<< _redeemers .~
117
118
[ Redeemer
118
119
{ index: BigNum .one
@@ -122,7 +123,7 @@ editorTests = group "Cardano.Transaction.Edit" do
122
123
}
123
124
]
124
125
# _body <<< _inputs .~ [ input0, input1, input2 ]
125
- tx' = mainnetTransaction
126
+ tx' = anyNetworkTx
126
127
# _witnessSet <<< _redeemers .~
127
128
[ Redeemer
128
129
{ index: BigNum .zero
@@ -137,7 +138,7 @@ editorTests = group "Cardano.Transaction.Edit" do
137
138
`shouldEqual` pure tx'
138
139
test " remove two inputs with redeemers, before and after" do
139
140
let
140
- tx = mainnetTransaction
141
+ tx = anyNetworkTx
141
142
# _witnessSet <<< _redeemers .~
142
143
[ Redeemer
143
144
{ index: BigNum .zero
@@ -159,7 +160,7 @@ editorTests = group "Cardano.Transaction.Edit" do
159
160
}
160
161
]
161
162
# _body <<< _inputs .~ [ input0, input1, input2 ]
162
- tx' = mainnetTransaction
163
+ tx' = anyNetworkTx
163
164
# _witnessSet <<< _redeemers .~
164
165
[ Redeemer
165
166
{ index: BigNum .zero
@@ -174,7 +175,7 @@ editorTests = group "Cardano.Transaction.Edit" do
174
175
`shouldEqual` pure tx'
175
176
test " remove input & redeemer, add another input & redeemer" do
176
177
let
177
- tx = mainnetTransaction
178
+ tx = anyNetworkTx
178
179
# _witnessSet <<< _redeemers .~
179
180
[ Redeemer
180
181
{ index: BigNum .zero
@@ -190,7 +191,7 @@ editorTests = group "Cardano.Transaction.Edit" do
190
191
}
191
192
]
192
193
# _body <<< _inputs .~ [ input1, input2 ]
193
- tx' = mainnetTransaction
194
+ tx' = anyNetworkTx
194
195
# _witnessSet <<< _redeemers .~
195
196
-- order is swapped because of `nub`...
196
197
[ Redeemer
@@ -236,10 +237,10 @@ builderTests = group "Cardano.Transaction.Builder" do
236
237
PlutusScriptOutput (ScriptReference input1 SpendInput ) RedeemerDatum .unit Nothing
237
238
group " SpendOutput" do
238
239
testBuilderSteps " PKH output" [ SpendOutput pkhUtxo Nothing ] $
239
- mainnetTransaction # _body <<< _inputs .~ [ input1 ]
240
+ anyNetworkTx # _body <<< _inputs .~ [ input1 ]
240
241
testBuilderSteps " PKH output x2 -> 1"
241
242
[ SpendOutput pkhUtxo Nothing , SpendOutput pkhUtxo Nothing ] $
242
- mainnetTransaction # _body <<< _inputs .~ [ input1 ]
243
+ anyNetworkTx # _body <<< _inputs .~ [ input1 ]
243
244
testBuilderStepsFail " PKH output with wrong witness"
244
245
[ SpendOutput pkhUtxo (Just nsWitness) ] $
245
246
WrongOutputType ScriptHashWitness pkhUtxo
@@ -252,24 +253,24 @@ builderTests = group "Cardano.Transaction.Builder" do
252
253
test " PKH output with wrong NetworkId" do
253
254
let
254
255
result =
255
- buildTransaction TestnetId
256
+ modifyTransaction testnetTransaction
256
257
[ SpendOutput pkhUtxo Nothing ]
257
258
result `shouldEqual`
258
259
Left (WrongNetworkId $ pkhUtxo ^. _output <<< _address)
259
260
group " Pay" do
260
261
testBuilderSteps " #1" [ Pay pkhOutput ] $
261
- mainnetTransaction # _body <<< _outputs .~ [ pkhOutput ]
262
+ anyNetworkTx # _body <<< _outputs .~ [ pkhOutput ]
262
263
group " MintAsset" do
263
264
testBuilderSteps " #1" [ Pay pkhOutput ] $
264
- mainnetTransaction # _body <<< _outputs .~ [ pkhOutput ]
265
+ anyNetworkTx # _body <<< _outputs .~ [ pkhOutput ]
265
266
group " Deregister" do
266
267
testBuilderSteps " Deregister script"
267
268
[ IssueCertificate
268
269
(StakeDeregistration (wrap $ ScriptHashCredential $ PlutusScript .hash script1))
269
270
$ Just
270
271
$ PlutusScriptCredential (ScriptValue script1) RedeemerDatum .unit
271
272
] $
272
- mainnetTransaction
273
+ anyNetworkTx
273
274
# _witnessSet <<< _plutusScripts .~ [ script1 ]
274
275
# _witnessSet <<< _redeemers .~
275
276
[ Redeemer
@@ -304,7 +305,7 @@ testBuilderStepsFail
304
305
-> TestPlanM (Aff Unit ) Unit
305
306
testBuilderStepsFail label steps err = test label do
306
307
let
307
- result = buildTransaction MainnetId steps
308
+ result = buildTransaction steps
308
309
result `shouldEqual` Left err
309
310
310
311
testBuilderSteps
@@ -314,7 +315,7 @@ testBuilderSteps
314
315
-> TestPlanM (Aff Unit ) Unit
315
316
testBuilderSteps label steps expected = test label do
316
317
let
317
- result = buildTransaction MainnetId steps
318
+ result = buildTransaction steps
318
319
result `shouldEqual` Right expected
319
320
320
321
pkhOutput :: TransactionOutput
@@ -426,5 +427,8 @@ script1 = unsafePartial $ fromJust $ decodeCbor $ wrap $ hexToByteArrayUnsafe "4
426
427
script2 :: PlutusScript
427
428
script2 = unsafePartial $ fromJust $ decodeCbor $ wrap $ hexToByteArrayUnsafe " 4e4d01000033222220051200120012"
428
429
429
- mainnetTransaction :: Transaction
430
- mainnetTransaction = Transaction .empty # _body <<< _networkId .~ Just MainnetId
430
+ anyNetworkTx :: Transaction
431
+ anyNetworkTx = Transaction .empty
432
+
433
+ testnetTransaction :: Transaction
434
+ testnetTransaction = Transaction .empty # _body <<< _networkId .~ Just TestnetId
0 commit comments