@@ -7,7 +7,7 @@ import { StateStore } from "@packages/core-state/src/stores/state";
77import { Generators } from "@packages/core-test-framework/src" ;
88import { Factories , FactoryBuilder } from "@packages/core-test-framework/src/factories" ;
99import passphrases from "@packages/core-test-framework/src/internal/passphrases.json" ;
10- import { InsufficientBalanceError } from "@packages/core-transactions/src/errors" ;
10+ import { InsufficientBalanceError , DisabledMultiSignatureSending , DisabledMultiSignatureReceiving } from "@packages/core-transactions/src/errors" ;
1111import { TransactionHandler } from "@packages/core-transactions/src/handlers" ;
1212import { TransactionHandlerRegistry } from "@packages/core-transactions/src/handlers/handler-registry" ;
1313import { Crypto , Enums , Interfaces , Managers , Transactions , Utils } from "@packages/crypto" ;
@@ -18,6 +18,7 @@ import {
1818 buildMultiSignatureWallet ,
1919 buildRecipientWallet ,
2020 buildSecondSignatureWallet ,
21+ buildMultiSignatureRecipientWallet ,
2122 buildSenderWallet ,
2223 initApp ,
2324} from "../__support__/app" ;
@@ -26,6 +27,7 @@ let app: Application;
2627let senderWallet : Wallets . Wallet ;
2728let secondSignatureWallet : Wallets . Wallet ;
2829let multiSignatureWallet : Wallets . Wallet ;
30+ let multiSignatureRecipientWallet : Wallets . Wallet ;
2931let recipientWallet : Wallets . Wallet ;
3032let walletRepository : Contracts . State . WalletRepository ;
3133let factoryBuilder : FactoryBuilder ;
@@ -59,11 +61,13 @@ beforeEach(() => {
5961 senderWallet = buildSenderWallet ( factoryBuilder ) ;
6062 secondSignatureWallet = buildSecondSignatureWallet ( factoryBuilder ) ;
6163 multiSignatureWallet = buildMultiSignatureWallet ( ) ;
64+ multiSignatureRecipientWallet = buildMultiSignatureRecipientWallet ( ) ;
6265 recipientWallet = buildRecipientWallet ( factoryBuilder ) ;
6366
6467 walletRepository . index ( senderWallet ) ;
6568 walletRepository . index ( secondSignatureWallet ) ;
6669 walletRepository . index ( multiSignatureWallet ) ;
70+ walletRepository . index ( multiSignatureRecipientWallet ) ;
6771 walletRepository . index ( recipientWallet ) ;
6872} ) ;
6973
@@ -156,12 +160,22 @@ describe("MultiPaymentTransaction", () => {
156160 ) . toResolve ( ) ;
157161 } ) ;
158162
159- it ( "should not throw - multi sign" , async ( ) => {
163+ it ( "should not throw - multi sign if and multiSignatureSendingEnabled=true" , async ( ) => {
164+ Managers . configManager . getMilestone ( ) . multiSignatureSendingEnabled = true ;
160165 await expect (
161166 handler . throwIfCannotBeApplied ( multiSignatureMultiPaymentTransaction , multiSignatureWallet ) ,
162167 ) . toResolve ( ) ;
163168 } ) ;
164169
170+ it ( "should throw - multi sign if and multiSignatureSendingEnabled=false" , async ( ) => {
171+ Managers . configManager . getMilestone ( ) . multiSignatureSendingEnabled = false ;
172+ await expect (
173+ handler . throwIfCannotBeApplied ( multiSignatureMultiPaymentTransaction , multiSignatureWallet ) ,
174+ ) . rejects . toThrow (
175+ DisabledMultiSignatureSending ,
176+ ) ;
177+ } ) ;
178+
165179 it ( "should throw if asset is undefined" , async ( ) => {
166180 multiPaymentTransaction . data . asset = undefined ;
167181
@@ -183,6 +197,35 @@ describe("MultiPaymentTransaction", () => {
183197 InsufficientBalanceError ,
184198 ) ;
185199 } ) ;
200+
201+ it ( "should not throw if recipient is multisignature wallet and multiSignatureReceivingEnabled=true" , async ( ) => {
202+ Managers . configManager . getMilestone ( ) . multiSignatureReceivingEnabled = true ;
203+ const multiPaymentTransaction = BuilderFactory . multiPayment ( )
204+ . addPayment ( "ARYJmeYHSUTgbxaiqsgoPwf6M3CYukqdKN" , "10" )
205+ . addPayment ( "AFyjB5jULQiYNsp37wwipCm9c7V1xEzTJD" , "20" )
206+ . addPayment ( multiSignatureRecipientWallet . getAddress ( ) , "20" )
207+ . nonce ( "1" )
208+ . sign ( passphrases [ 0 ] )
209+ . build ( ) ;
210+
211+ await expect ( handler . throwIfCannotBeApplied ( multiPaymentTransaction , senderWallet ) ) . toResolve ( ) ;
212+ } ) ;
213+
214+ it ( "should throw if recipient is multisignature wallet and multiSignatureReceivingEnabled=false" , async ( ) => {
215+ Managers . configManager . getMilestone ( ) . multiSignatureReceivingEnabled = false ;
216+ const multiPaymentTransaction = BuilderFactory . multiPayment ( )
217+ . addPayment ( "ARYJmeYHSUTgbxaiqsgoPwf6M3CYukqdKN" , "10" )
218+ . addPayment ( "AFyjB5jULQiYNsp37wwipCm9c7V1xEzTJD" , "20" )
219+ . addPayment ( multiSignatureRecipientWallet . getAddress ( ) , "20" )
220+ . nonce ( "1" )
221+ . sign ( passphrases [ 0 ] )
222+ . build ( ) ;
223+
224+ await expect ( handler . throwIfCannotBeApplied ( multiPaymentTransaction , senderWallet ) ) . rejects . toThrow (
225+ DisabledMultiSignatureReceiving ,
226+ ) ;
227+ } ) ;
228+
186229 } ) ;
187230
188231 describe ( "apply" , ( ) => {
0 commit comments