1+ import { coins } from '@bitgo/statics' ;
2+ import * as assert from 'assert' ;
3+ import { Flrp } from '../../src/flrp' ;
14import { BitGoBase } from '@bitgo/sdk-core' ;
25import { TestBitGo , TestBitGoAPI } from '@bitgo/sdk-test' ;
36import { BitGoAPI } from '@bitgo/sdk-api' ;
4- import { Flrp } from '../../src/flrp' ;
5- import { coins } from '@bitgo/statics' ;
67
78describe ( 'Flrp' , function ( ) {
89 let bitgo : TestBitGoAPI ;
10+ const staticsCoin = coins . get ( 'flrp' ) ;
911
1012 before ( function ( ) {
1113 bitgo = TestBitGo . decorate ( BitGoAPI , { env : 'mock' } ) ;
@@ -17,18 +19,85 @@ describe('Flrp', function () {
1719 ) ;
1820 } ) ;
1921
20- it ( 'createInstance returns a Flrp instance' , function ( ) {
21- const staticsCoin = coins . get ( 'flrp' ) ;
22- const coin = Flrp . createInstance ( bitgo as unknown as BitGoBase , staticsCoin ) ;
23- coin . should . be . instanceOf ( Flrp ) ;
22+ describe ( 'createInstance' , function ( ) {
23+ it ( 'should return a Flrp instance' , function ( ) {
24+ const coin = Flrp . createInstance ( bitgo as unknown as BitGoBase , staticsCoin ) ;
25+ assert . ok ( coin instanceof Flrp ) ;
26+ } ) ;
27+
28+ it ( 'should produce distinct objects on multiple calls' , function ( ) {
29+ const a = Flrp . createInstance ( bitgo as unknown as BitGoBase , staticsCoin ) ;
30+ const b = Flrp . createInstance ( bitgo as unknown as BitGoBase , staticsCoin ) ;
31+ assert . notStrictEqual ( a , b ) ;
32+ assert . ok ( a instanceof Flrp ) ;
33+ assert . ok ( b instanceof Flrp ) ;
34+ } ) ;
2435 } ) ;
2536
26- it ( 'multiple createInstance calls produce distinct objects' , function ( ) {
27- const sc = coins . get ( 'flrp' ) ;
28- const a = Flrp . createInstance ( bitgo as unknown as BitGoBase , sc ) ;
29- const b = Flrp . createInstance ( bitgo as unknown as BitGoBase , sc ) ;
30- a . should . not . equal ( b ) ;
31- a . should . be . instanceOf ( Flrp ) ;
32- b . should . be . instanceOf ( Flrp ) ;
37+ describe ( 'coin properties' , function ( ) {
38+ let coin : Flrp ;
39+
40+ beforeEach ( function ( ) {
41+ coin = Flrp . createInstance ( bitgo as unknown as BitGoBase , staticsCoin ) as Flrp ;
42+ } ) ;
43+
44+ it ( 'should have correct coin family' , function ( ) {
45+ assert . strictEqual ( coin . getFamily ( ) , staticsCoin . family ) ;
46+ } ) ;
47+
48+ it ( 'should have correct coin name' , function ( ) {
49+ assert . strictEqual ( coin . getFullName ( ) , staticsCoin . fullName ) ;
50+ } ) ;
51+
52+ it ( 'should have correct base factor' , function ( ) {
53+ assert . strictEqual ( coin . getBaseFactor ( ) , Math . pow ( 10 , staticsCoin . decimalPlaces ) ) ;
54+ } ) ;
55+
56+ it ( 'should validate addresses using utils' , function ( ) {
57+ const validAddress = 'flare1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq6f4avh' ;
58+ const result = coin . isValidAddress ( validAddress ) ;
59+ assert . strictEqual ( typeof result , 'boolean' ) ;
60+ } ) ;
61+
62+ it ( 'should generate key pairs' , function ( ) {
63+ const keyPair = coin . generateKeyPair ( ) ;
64+ assert . ok ( 'pub' in keyPair ) ;
65+ assert . ok ( 'prv' in keyPair ) ;
66+ if ( keyPair . pub && keyPair . prv ) {
67+ assert . strictEqual ( typeof keyPair . pub , 'string' ) ;
68+ assert . strictEqual ( typeof keyPair . prv , 'string' ) ;
69+ }
70+ } ) ;
71+ } ) ;
72+
73+ describe ( 'error handling' , function ( ) {
74+ it ( 'should handle construction with invalid parameters' , function ( ) {
75+ assert . throws ( ( ) => Flrp . createInstance ( null as unknown as BitGoBase , staticsCoin ) ) ;
76+ assert . throws ( ( ) => Flrp . createInstance ( bitgo as unknown as BitGoBase , null as unknown as typeof staticsCoin ) ) ;
77+ } ) ;
78+ } ) ;
79+
80+ describe ( 'inheritance and methods' , function ( ) {
81+ let coin : Flrp ;
82+
83+ beforeEach ( function ( ) {
84+ coin = Flrp . createInstance ( bitgo as unknown as BitGoBase , staticsCoin ) as Flrp ;
85+ } ) ;
86+
87+ it ( 'should have required base coin methods' , function ( ) {
88+ assert . ok ( 'getFamily' in coin ) ;
89+ assert . ok ( 'getFullName' in coin ) ;
90+ assert . ok ( 'getBaseFactor' in coin ) ;
91+ assert . ok ( 'isValidAddress' in coin ) ;
92+ assert . ok ( 'generateKeyPair' in coin ) ;
93+ } ) ;
94+
95+ it ( 'should handle address validation consistently' , function ( ) {
96+ const validAddress = 'flare1test' ;
97+ const invalidAddress = 'invalid-address' ;
98+
99+ assert . strictEqual ( typeof coin . isValidAddress ( validAddress ) , 'boolean' ) ;
100+ assert . strictEqual ( typeof coin . isValidAddress ( invalidAddress ) , 'boolean' ) ;
101+ } ) ;
33102 } ) ;
34103} ) ;
0 commit comments