File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -600,6 +600,56 @@ describe('Rosetta API', () => {
600
600
expect ( JSON . parse ( result1 . text ) ) . toEqual ( expectedResponse ) ;
601
601
} ) ;
602
602
603
+ test ( 'account/balance - fees calculated properly' , async ( ) => {
604
+ // this account has made one transaction
605
+ // ensure that the fees for it are calculated after it makes
606
+ // the transaction, not before, by checking its balance in block 1
607
+ const stxAddress = 'ST1HB1T8WRNBYB0Y3T7WXZS38NKKPTBR3EG9EPJKR' ;
608
+ const request1 : RosettaAccountBalanceRequest = {
609
+ network_identifier : {
610
+ blockchain : 'stacks' ,
611
+ network : 'testnet' ,
612
+ } ,
613
+ block_identifier : {
614
+ index : 1 ,
615
+ } ,
616
+ account_identifier : {
617
+ address : stxAddress ,
618
+ } ,
619
+ } ;
620
+
621
+ const result1 = await supertest ( api . server ) . post ( `/rosetta/v1/account/balance/` ) . send ( request1 ) ;
622
+ console . log ( 'account balance' , result1 . text ) ;
623
+ expect ( result1 . status ) . toBe ( 200 ) ;
624
+ expect ( result1 . type ) . toBe ( 'application/json' ) ;
625
+
626
+ const block = await api . datastore . getBlockByHeight ( 1 ) ;
627
+ assert ( block . found ) ;
628
+
629
+ const amount : RosettaAmount = {
630
+ value : '0' ,
631
+ currency : {
632
+ symbol : 'STX' ,
633
+ decimals : 6 ,
634
+ } ,
635
+ } ;
636
+
637
+ const expectedResponse : RosettaAccountBalanceResponse = {
638
+ block_identifier : {
639
+ hash : block . result . block_hash ,
640
+ index : block . result . block_height ,
641
+ } ,
642
+ balances : [ amount ] ,
643
+
644
+ coins : [ ] ,
645
+ metadata : {
646
+ sequence_number : 0 ,
647
+ } ,
648
+ } ;
649
+
650
+ expect ( JSON . parse ( result1 . text ) ) . toEqual ( expectedResponse ) ;
651
+ } ) ;
652
+
603
653
test ( 'account/balance - invalid account identifier' , async ( ) => {
604
654
const request : RosettaAccountBalanceRequest = {
605
655
network_identifier : {
You can’t perform that action at this time.
0 commit comments