|
1 | | -import { CoinFamily } from '../../src'; |
| 1 | +import { CoinFamily, CoinFeature, coins } from '../../src'; |
2 | 2 |
|
3 | 3 | const should = require('should'); |
4 | 4 | const { UnderlyingAsset } = require('../../src/base'); |
| 5 | +const { solToken, ProgramID } = require('../../src/account'); |
5 | 6 |
|
6 | 7 | describe('UnderlyingAsset', function () { |
7 | 8 | it('UnderlyingAsset values should be unique', function () { |
@@ -36,3 +37,88 @@ describe('zkSync Era Base Types', function () { |
36 | 37 | UnderlyingAsset.ZKSYNCERA.should.equal('zksyncera'); |
37 | 38 | }); |
38 | 39 | }); |
| 40 | + |
| 41 | +describe('Tokenized Equity CoinFeatures', function () { |
| 42 | + it('TOKENIZED_EQUITY feature value should be tokenized-equity', function () { |
| 43 | + CoinFeature.TOKENIZED_EQUITY.should.equal('tokenized-equity'); |
| 44 | + }); |
| 45 | + |
| 46 | + it('BITGO_TOKENIZED_EQUITY feature value should be bitgo-tokenized-equity', function () { |
| 47 | + CoinFeature.BITGO_TOKENIZED_EQUITY.should.equal('bitgo-tokenized-equity'); |
| 48 | + }); |
| 49 | + |
| 50 | + it('sol:gospcx should have both TOKENIZED_EQUITY and BITGO_TOKENIZED_EQUITY', function () { |
| 51 | + const coin = coins.get('sol:gospcx'); |
| 52 | + coin.features.should.containEql(CoinFeature.TOKENIZED_EQUITY); |
| 53 | + coin.features.should.containEql(CoinFeature.BITGO_TOKENIZED_EQUITY); |
| 54 | + }); |
| 55 | + |
| 56 | + it('tsol:gospcx should have both TOKENIZED_EQUITY and BITGO_TOKENIZED_EQUITY', function () { |
| 57 | + const coin = coins.get('tsol:gospcx'); |
| 58 | + coin.features.should.containEql(CoinFeature.TOKENIZED_EQUITY); |
| 59 | + coin.features.should.containEql(CoinFeature.BITGO_TOKENIZED_EQUITY); |
| 60 | + }); |
| 61 | + |
| 62 | + it('tsol:stggospcx should have both TOKENIZED_EQUITY and BITGO_TOKENIZED_EQUITY', function () { |
| 63 | + const coin = coins.get('tsol:stggospcx'); |
| 64 | + coin.features.should.containEql(CoinFeature.TOKENIZED_EQUITY); |
| 65 | + coin.features.should.containEql(CoinFeature.BITGO_TOKENIZED_EQUITY); |
| 66 | + }); |
| 67 | + |
| 68 | + it('ofcsol:gospcx should have both TOKENIZED_EQUITY and BITGO_TOKENIZED_EQUITY', function () { |
| 69 | + const coin = coins.get('ofcsol:gospcx'); |
| 70 | + coin.features.should.containEql(CoinFeature.TOKENIZED_EQUITY); |
| 71 | + coin.features.should.containEql(CoinFeature.BITGO_TOKENIZED_EQUITY); |
| 72 | + }); |
| 73 | + |
| 74 | + it('ofctsol:gospcx should have both TOKENIZED_EQUITY and BITGO_TOKENIZED_EQUITY', function () { |
| 75 | + const coin = coins.get('ofctsol:gospcx'); |
| 76 | + coin.features.should.containEql(CoinFeature.TOKENIZED_EQUITY); |
| 77 | + coin.features.should.containEql(CoinFeature.BITGO_TOKENIZED_EQUITY); |
| 78 | + }); |
| 79 | + |
| 80 | + it('ofctsol:stggospcx should have both TOKENIZED_EQUITY and BITGO_TOKENIZED_EQUITY', function () { |
| 81 | + const coin = coins.get('ofctsol:stggospcx'); |
| 82 | + coin.features.should.containEql(CoinFeature.TOKENIZED_EQUITY); |
| 83 | + coin.features.should.containEql(CoinFeature.BITGO_TOKENIZED_EQUITY); |
| 84 | + }); |
| 85 | + |
| 86 | + it('invariant: BITGO_TOKENIZED_EQUITY without TOKENIZED_EQUITY should throw MissingRequiredCoinFeatureError', function () { |
| 87 | + let threw = false; |
| 88 | + let errorMessage = ''; |
| 89 | + let errorType = ''; |
| 90 | + try { |
| 91 | + solToken( |
| 92 | + '00000000-0000-0000-0000-000000000001', |
| 93 | + 'test:invalidgostock', |
| 94 | + 'Invalid goStock', |
| 95 | + 6, |
| 96 | + 'AAVvaNDwkGfxGNaf1HJ5JzfwDb1PYmAgXSixRsczyrk4', |
| 97 | + 'AAVvaNDwkGfxGNaf1HJ5JzfwDb1PYmAgXSixRsczyrk4', |
| 98 | + UnderlyingAsset['sol:gospcx'], |
| 99 | + [ |
| 100 | + CoinFeature.ACCOUNT_MODEL, |
| 101 | + CoinFeature.REQUIRES_BIG_NUMBER, |
| 102 | + CoinFeature.VALUELESS_TRANSFER, |
| 103 | + CoinFeature.TRANSACTION_DATA, |
| 104 | + CoinFeature.CUSTODY, |
| 105 | + CoinFeature.CUSTODY_BITGO_TRUST, |
| 106 | + CoinFeature.TSS, |
| 107 | + CoinFeature.TSS_COLD, |
| 108 | + CoinFeature.BULK_TRANSACTION, |
| 109 | + CoinFeature.BITGO_TOKENIZED_EQUITY, |
| 110 | + ], |
| 111 | + ProgramID.Token2022ProgramId |
| 112 | + ); |
| 113 | + } catch (err: unknown) { |
| 114 | + threw = true; |
| 115 | + if (err instanceof Error) { |
| 116 | + errorMessage = err.message; |
| 117 | + errorType = err.constructor.name; |
| 118 | + } |
| 119 | + } |
| 120 | + threw.should.be.true(); |
| 121 | + errorType.should.equal('MissingRequiredCoinFeatureError'); |
| 122 | + errorMessage.should.containEql('tokenized-equity'); |
| 123 | + }); |
| 124 | +}); |
0 commit comments