@@ -43,6 +43,31 @@ describe('Tao Token Transfer Builder', function () {
4343
4444 SinonAssert . callCount ( spyValidateAddress , 4 ) ;
4545 } ) ;
46+
47+ it ( 'should validate netuid' , function ( ) {
48+ const spyValidateAddress = spy ( builder , 'validateNetuid' ) ;
49+ assert . throws (
50+ ( ) => builder . destinationNetuid ( 'abc' ) ,
51+ ( e : Error ) => e . message === `Cannot convert abc to a BigInt`
52+ ) ;
53+ assert . throws (
54+ ( ) => builder . destinationNetuid ( '-10' ) ,
55+ ( e : Error ) => e . message === `The netuid '-10' is not a valid netuid`
56+ ) ;
57+ should . doesNotThrow ( ( ) => builder . destinationNetuid ( '36' ) ) ;
58+
59+ assert . throws (
60+ ( ) => builder . originNetuid ( 'abc' ) ,
61+ ( e : Error ) => e . message === `Cannot convert abc to a BigInt`
62+ ) ;
63+ assert . throws (
64+ ( ) => builder . destinationNetuid ( '-1' ) ,
65+ ( e : Error ) => e . message === `The netuid '-1' is not a valid netuid`
66+ ) ;
67+ should . doesNotThrow ( ( ) => builder . originNetuid ( '64' ) ) ;
68+
69+ SinonAssert . callCount ( spyValidateAddress , 6 ) ;
70+ } ) ;
4671 } ) ;
4772
4873 describe ( 'build transfer stake transaction' , function ( ) {
@@ -51,8 +76,8 @@ describe('Tao Token Transfer Builder', function () {
5176 . amount ( '9007199254740995' )
5277 . destinationColdkey ( '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' )
5378 . hotkey ( '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' )
54- . originNetuid ( '1 ' )
55- . destinationNetuid ( '1 ' )
79+ . originNetuid ( '12 ' )
80+ . destinationNetuid ( '10 ' )
5681 . sender ( { address : sender . address } )
5782 . validity ( { firstValid : 3933 , maxDuration : 64 } )
5883 . referenceBlock ( referenceBlock )
@@ -65,7 +90,7 @@ describe('Tao Token Transfer Builder', function () {
6590
6691 serializedTx . should . equal ( rawTx . transferStake . signed ) ;
6792 tx . toJson ( ) . should . deepEqual ( {
68- id : '0xe5ce9ff1bbdf54d1dbd5adee8648027aa7efa99d319b041afb4b57be2042fc11 ' ,
93+ id : '0xe5932b507a53d351aabd520487ba55ba833e0968ad18642a28f54dabeb7abf2f ' ,
6994 sender : '5EGoFA95omzemRssELLDjVenNZ68aXyUeqtKQScXSEBvVJkr' ,
7095 referenceBlock : '0x149799bc9602cb5cf201f3425fb8d253b2d4e61fc119dcab3249f307f594754d' ,
7196 blockNumber : 3933 ,
@@ -78,19 +103,10 @@ describe('Tao Token Transfer Builder', function () {
78103 tip : 0 ,
79104 destinationColdkey : '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' ,
80105 hotkey : '5FCPTnjevGqAuTttetBy4a24Ej3pH9fiQ8fmvP1ZkrVsLUoT' ,
81- originNetuid : '1 ' ,
82- destinationNetuid : '1 ' ,
106+ originNetuid : '12 ' ,
107+ destinationNetuid : '10 ' ,
83108 alphaAmount : '9007199254740995' ,
84109 } ) ;
85- tx . explainTransaction ( ) . should . containDeep ( {
86- outputs : [
87- {
88- address : '5Ffp1wJCPu4hzVDTo7XaMLqZSvSadyUQmxWPDw74CBjECSoq' ,
89- amount : '9007199254740995' ,
90- tokenName : 'ttao:apex' ,
91- } ,
92- ] ,
93- } ) ;
94110 } ) ;
95111
96112 it ( 'should re-build from raw signed tx' , async function ( ) {
0 commit comments