File tree Expand file tree Collapse file tree 3 files changed +10
-1
lines changed
Expand file tree Collapse file tree 3 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,9 @@ export class Utils implements BaseUtils {
2525 /** @inheritdoc */
2626 isValidBlockId ( hash : string ) : boolean {
2727 // In canton, there is no block hash, we store the height as the _id (hash)
28- const blockHeight = Number ( hash ) ;
28+ // this will be of the form, <blockHeight>_<version>
29+ const [ height ] = hash . split ( '_' ) ;
30+ const blockHeight = Number ( height ) ;
2931 return ! isNaN ( blockHeight ) && blockHeight > 0 ;
3032 }
3133
Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ export const CANTON_ADDRESSES = {
100100
101101export const CANTON_BLOCK_HEIGHT = {
102102 VALID_HASH: '123456',
103+ VALID_HASH_WITH_VERSION: '123456_5.1.0',
103104 INVALID_BLOCK_HASH: 'xyz',
104105 NEGATIVE_BLOCK_HASH: '-100',
105106};
Original file line number Diff line number Diff line change @@ -162,6 +162,12 @@ describe('Canton Util', function () {
162162 assert . strictEqual ( isValid , true ) ;
163163 } ) ;
164164
165+ it ( 'should return true when the block hash has version' , function ( ) {
166+ const isValid = utils . isValidBlockId ( CANTON_BLOCK_HEIGHT . VALID_HASH_WITH_VERSION ) ;
167+ should . exist ( isValid ) ;
168+ assert . strictEqual ( isValid , true ) ;
169+ } ) ;
170+
165171 it ( 'should return false when the block hash is not a number' , function ( ) {
166172 const isValid = utils . isValidBlockId ( CANTON_BLOCK_HEIGHT . INVALID_BLOCK_HASH ) ;
167173 should . exist ( isValid ) ;
You can’t perform that action at this time.
0 commit comments