-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update MessageTopic serialization, MessageAddr key parsing
- Loading branch information
1 parent
1e987fb
commit 1d536e5
Showing
7 changed files
with
339 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { expect } from 'chai'; | ||
|
||
import { MessageAddr } from './MessageAddr'; | ||
import { Key, KeyTypeID } from './Key'; | ||
|
||
describe('Key', () => { | ||
const hashAddr = | ||
'55d4a6915291da12afded37fa5bc01f0803a2f0faf6acb7ec4c7ca6ab76f3330'; | ||
const topicStr = | ||
'5721a6d9d7a9afe5dfdb35276fb823bed0f825350e4d865a5ec0110c380de4e1'; | ||
const msgKeyStr = `message-topic-${hashAddr}-${topicStr}`; | ||
|
||
it('should correctly parse a key with hash address, topic hash, and index', () => { | ||
const messageAddr = MessageAddr.fromString(msgKeyStr); | ||
expect(messageAddr.hashAddr.toHex()).to.equal(hashAddr); | ||
expect(messageAddr.topicNameHash.toHex()).to.equal(topicStr); | ||
}); | ||
|
||
it('should correctly create a new key for message by type', () => { | ||
const key = Key.createByType(msgKeyStr, KeyTypeID.Message); | ||
|
||
expect(key.toPrefixedString()).to.equal(msgKeyStr); | ||
expect(key.message?.hashAddr.toHex()).to.equal(hashAddr); | ||
expect(key.message?.topicNameHash.toHex()).to.equal(topicStr); | ||
}); | ||
|
||
it('should correctly create a new key for message', () => { | ||
const key = Key.newKey(msgKeyStr); | ||
|
||
expect(key.toPrefixedString()).to.equal(msgKeyStr); | ||
expect(key.message?.hashAddr.toHex()).to.equal(hashAddr); | ||
expect(key.message?.topicNameHash.toHex()).to.equal(topicStr); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.