@@ -768,16 +768,117 @@ describe("HbarTransferLayout.vue", () => {
768768 expect ( compactLayout . sources . length ) . toBe ( 1 )
769769 expect ( compactLayout . destinations . length ) . toBe ( 1 )
770770
771- const cs0 = fullLayout . sources [ 0 ]
771+ const cs0 = compactLayout . sources [ 0 ]
772772 expect ( cs0 . transfer . account ) . toBe ( "0.0.1859883" )
773773 expect ( cs0 . transfer . amount ) . toBe ( - 9100185749 )
774774 expect ( cs0 . description ) . toBe ( null )
775775 expect ( cs0 . payload ) . toBe ( true )
776776
777- const cd0 = fullLayout . destinations [ 0 ]
777+ const cd0 = compactLayout . destinations [ 0 ]
778778 expect ( cd0 . transfer . account ) . toBe ( "0.0.2105083" )
779779 expect ( cd0 . transfer . amount ) . toBe ( + 9100000000 )
780780 expect ( cd0 . description ) . toBe ( "Transfer" )
781781 expect ( cd0 . payload ) . toBe ( true )
782782 } )
783+
784+
785+ test ( "Transfer and payment of reward (take #2)" , async ( ) => {
786+
787+ const transaction = {
788+ "charged_tx_fee" : 118031 ,
789+ "transfers" : [
790+ {
791+ "account" : "0.0.3" ,
792+ "amount" : 4798 ,
793+ "is_approval" : false
794+ } ,
795+ {
796+ "account" : "0.0.98" ,
797+ "amount" : 113233 ,
798+ "is_approval" : false
799+ } ,
800+ {
801+ "account" : "0.0.800" ,
802+ "amount" : - 231664272 ,
803+ "is_approval" : false
804+ } ,
805+ {
806+ "account" : "0.0.1784243" ,
807+ "amount" : - 118046 ,
808+ "is_approval" : false
809+ } ,
810+ {
811+ "account" : "0.0.1934439" ,
812+ "amount" : 231664287 ,
813+ "is_approval" : false
814+ }
815+ ] ,
816+ "staking_reward_transfers" : [
817+ {
818+ "account" : "0.0.1934439" ,
819+ "amount" : 231664272
820+ }
821+ ]
822+ } as Transaction
823+
824+ //
825+ // FULL
826+ //
827+
828+ const fullLayout = new HbarTransferLayout ( transaction , NETWORK_NODES )
829+
830+ expect ( fullLayout . transaction ) . toBe ( transaction )
831+ // expect(fullLayout.destinationAmount).toBe(+TransferTotal)
832+ expect ( fullLayout . rowCount ) . toBe ( 3 )
833+ expect ( fullLayout . sources . length ) . toBe ( 1 )
834+ expect ( fullLayout . destinations . length ) . toBe ( 3 )
835+
836+ const s0 = fullLayout . sources [ 0 ]
837+ expect ( s0 . transfer . account ) . toBe ( "0.0.1784243" )
838+ expect ( s0 . transfer . amount ) . toBe ( - 118046 )
839+ expect ( s0 . description ) . toBe ( null )
840+ expect ( s0 . payload ) . toBe ( true )
841+
842+ const d0 = fullLayout . destinations [ 0 ]
843+ expect ( d0 . transfer . account ) . toBe ( "0.0.1934439" )
844+ expect ( d0 . transfer . amount ) . toBe ( + 15 )
845+ expect ( d0 . description ) . toBe ( "Transfer" )
846+ expect ( d0 . payload ) . toBe ( true )
847+
848+ const d1 = fullLayout . destinations [ 1 ]
849+ expect ( d1 . transfer . account ) . toBe ( "0.0.3" )
850+ expect ( d1 . transfer . amount ) . toBe ( + 4798 )
851+ expect ( d1 . description ) . toBe ( "Node fee (Hedera)" )
852+ expect ( d1 . payload ) . toBe ( false )
853+
854+ const d2 = fullLayout . destinations [ 2 ]
855+ expect ( d2 . transfer . account ) . toBe ( "0.0.98" )
856+ expect ( d2 . transfer . amount ) . toBe ( + 113233 )
857+ expect ( d2 . description ) . toBe ( "Hedera fee collection account" )
858+ expect ( d2 . payload ) . toBe ( false )
859+
860+ //
861+ // COMPACT
862+ //
863+
864+ const compactLayout = new HbarTransferLayout ( transaction , NETWORK_NODES , false )
865+
866+ expect ( compactLayout . transaction ) . toBe ( transaction )
867+ expect ( compactLayout . destinationAmount ) . toBe ( + 15 )
868+ expect ( compactLayout . rowCount ) . toBe ( 1 )
869+ expect ( compactLayout . sources . length ) . toBe ( 1 )
870+ expect ( compactLayout . destinations . length ) . toBe ( 1 )
871+
872+ const cs0 = compactLayout . sources [ 0 ]
873+ expect ( cs0 . transfer . account ) . toBe ( "0.0.1784243" )
874+ expect ( cs0 . transfer . amount ) . toBe ( - 118046 )
875+ expect ( cs0 . description ) . toBe ( null )
876+ expect ( cs0 . payload ) . toBe ( true )
877+
878+ const cd0 = compactLayout . destinations [ 0 ]
879+ expect ( cd0 . transfer . account ) . toBe ( "0.0.1934439" )
880+ expect ( cd0 . transfer . amount ) . toBe ( + 15 )
881+ expect ( cd0 . description ) . toBe ( "Transfer" )
882+ expect ( cd0 . payload ) . toBe ( true )
883+ } )
783884} )
0 commit comments