File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -88,7 +88,10 @@ CREATE OR REPLACE FUNCTION acca.reject_tx(
8888 _tx_status acca .transaction_status ;
8989 BEGIN
9090 SELECT status INTO _tx_status FROM acca .transactions WHERE tx_id = _tx_id;
91- IF _tx_status <> ' auth' THEN
91+ IF _tx_status = ' draft' THEN
92+ DELETE FROM acca .requests_queue WHERE tx_id = _tx_id;
93+ RETURN;
94+ ELSEIF _tx_status <> ' auth' THEN
9295 RAISE EXCEPTION ' Transaction has already closed (or not found): status=%' , _tx_status::text ;
9396 END IF;
9497
Original file line number Diff line number Diff line change @@ -601,3 +601,166 @@ func Test01Basic_03ErrorInMiddle(t *testing.T) {
601601
602602 runTests (t , tests )
603603}
604+
605+ func Test01Basic_03SimpleTransferReject (t * testing.T ) {
606+ cur := "curr"
607+
608+ tests := []cmdBatch {
609+ {
610+ "InternalTransferWithHoldAndReject" ,
611+ []command {
612+ CmdInitAccounts (cur , []accountInfo {
613+ {
614+ AccKey : "11" ,
615+ Balance : 10 ,
616+ },
617+ {
618+ AccKey : "22" ,
619+ Balance : 20 ,
620+ },
621+ {
622+ AccKey : "33" ,
623+ Balance : 30 ,
624+ },
625+ {
626+ AccKey : "hold11" ,
627+ Balance : 0 ,
628+ },
629+ }),
630+ CmdTransfers ([]transfers {
631+ transfers {
632+ {
633+ SrcAcc : "11" ,
634+ DstAcc : "22" ,
635+ Type : Internal ,
636+ Amount : 9 ,
637+ Reason : "fortesting" ,
638+ Meta : MetaData {
639+ "foo" : "bar" ,
640+ },
641+ Hold : true ,
642+ HoldAcc : "hold11" ,
643+ },
644+ {
645+ SrcAcc : "22" ,
646+ DstAcc : "33" ,
647+ Type : Internal ,
648+ Amount : 19 ,
649+ Reason : "fortesting" ,
650+ Meta : MetaData {
651+ "foo" : "bar" ,
652+ },
653+ Hold : true ,
654+ HoldAcc : "hold11" ,
655+ },
656+ {
657+ SrcAcc : "33" ,
658+ DstAcc : "11" ,
659+ Type : Internal ,
660+ Amount : 29 ,
661+ Reason : "fortesting" ,
662+ Meta : MetaData {
663+ "foo" : "bar" ,
664+ },
665+ Hold : true ,
666+ HoldAcc : "hold11" ,
667+ },
668+ },
669+ }),
670+ CmdCheckStatuses ("draft" ),
671+ CmdExecute (1 ),
672+ CmdCheckStatuses ("auth" ),
673+ CmdCheckBalances (map [string ]int64 {
674+ "11" : 10 - 9 ,
675+ "22" : 20 - 19 ,
676+ "33" : 30 - 29 ,
677+ "hold11" : 9 + 19 + 29 ,
678+ }),
679+ CmdReject (0 ),
680+ CmdExecute (1 ),
681+ CmdCheckStatuses ("rejected" ),
682+ CmdCheckBalances (map [string ]int64 {
683+ "11" : 10 ,
684+ "22" : 20 ,
685+ "33" : 30 ,
686+ "hold11" : 0 ,
687+ }),
688+ },
689+ },
690+ {
691+ "InternalTransferWithHoldAndRejectInDraft" ,
692+ []command {
693+ CmdInitAccounts (cur , []accountInfo {
694+ {
695+ AccKey : "11" ,
696+ Balance : 10 ,
697+ },
698+ {
699+ AccKey : "22" ,
700+ Balance : 20 ,
701+ },
702+ {
703+ AccKey : "33" ,
704+ Balance : 30 ,
705+ },
706+ {
707+ AccKey : "hold11" ,
708+ Balance : 0 ,
709+ },
710+ }),
711+ CmdTransfers ([]transfers {
712+ transfers {
713+ {
714+ SrcAcc : "11" ,
715+ DstAcc : "22" ,
716+ Type : Internal ,
717+ Amount : 9 ,
718+ Reason : "fortesting" ,
719+ Meta : MetaData {
720+ "foo" : "bar" ,
721+ },
722+ Hold : true ,
723+ HoldAcc : "hold11" ,
724+ },
725+ {
726+ SrcAcc : "22" ,
727+ DstAcc : "33" ,
728+ Type : Internal ,
729+ Amount : 19 ,
730+ Reason : "fortesting" ,
731+ Meta : MetaData {
732+ "foo" : "bar" ,
733+ },
734+ Hold : true ,
735+ HoldAcc : "hold11" ,
736+ },
737+ {
738+ SrcAcc : "33" ,
739+ DstAcc : "11" ,
740+ Type : Internal ,
741+ Amount : 29 ,
742+ Reason : "fortesting" ,
743+ Meta : MetaData {
744+ "foo" : "bar" ,
745+ },
746+ Hold : true ,
747+ HoldAcc : "hold11" ,
748+ },
749+ },
750+ }),
751+ CmdCheckStatuses ("draft" ),
752+ CmdReject (0 ),
753+ CmdExecute (1 ),
754+ CmdCheckStatuses ("draft" ),
755+ CmdCheckBalances (map [string ]int64 {
756+ "11" : 10 ,
757+ "22" : 20 ,
758+ "33" : 30 ,
759+ "hold111" : 0 ,
760+ }),
761+ },
762+ },
763+ }
764+
765+ runTests (t , tests )
766+ }
You can’t perform that action at this time.
0 commit comments