mirror of
https://github.com/Permissionless-Software-Foundation/psf-memo-client.git
synced 2026-09-21 16:52:02 -07:00
Implement Set Name feature (0x6d01)
- Add MemoSetName service with 77-byte UTF-8 validation and broadcast. - Add SetNamePage controller with byte counter and navigation to /account. - Add AccountPage controller showing stored name and Set Name button. - Add Profiles session store to share the new name across pages. - Add React views /memo/set-name and /account, plus nav link. - Update acceptance handlers for set-name scenarios and fix fake wallet sendOpReturn signature to match public minimal-slp-wallet API. - Update existing post memo tests to match the corrected wallet API. By coder.
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
Unit tests for the session profile store (src/services/profiles.js).
|
||||
|
||||
The store indexes display names by BCH cash address so that pages can read
|
||||
a name immediately after it is broadcast.
|
||||
*/
|
||||
|
||||
'use strict'
|
||||
|
||||
const test = require('node:test')
|
||||
const assert = require('node:assert/strict')
|
||||
|
||||
const Profiles = require('../../src/services/profiles')
|
||||
|
||||
test('returns null when no name has been set for an address', () => {
|
||||
const profiles = new Profiles()
|
||||
assert.equal(profiles.getName('bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d'), null)
|
||||
})
|
||||
|
||||
test('stores and retrieves a name by address', () => {
|
||||
const profiles = new Profiles()
|
||||
const addr = 'bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d'
|
||||
profiles.setName(addr, 'trout')
|
||||
assert.equal(profiles.getName(addr), 'trout')
|
||||
})
|
||||
|
||||
test('updating a name overwrites the previous value', () => {
|
||||
const profiles = new Profiles()
|
||||
const addr = 'bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d'
|
||||
profiles.setName(addr, 'trout')
|
||||
profiles.setName(addr, 'salmon')
|
||||
assert.equal(profiles.getName(addr), 'salmon')
|
||||
})
|
||||
|
||||
test('different addresses keep independent names', () => {
|
||||
const profiles = new Profiles()
|
||||
const addr1 = 'bitcoincash:qqlrzp23w08434twmvr4fxw672whkjy0py26r63g3d'
|
||||
const addr2 = 'bitcoincash:qq0ktdlgekdszmxhmg7y6a90t9dpj6p0pg3gctn9e'
|
||||
profiles.setName(addr1, 'trout')
|
||||
profiles.setName(addr2, 'salmon')
|
||||
assert.equal(profiles.getName(addr1), 'trout')
|
||||
assert.equal(profiles.getName(addr2), 'salmon')
|
||||
})
|
||||
|
||||
test('ignores setName for a missing address', () => {
|
||||
const profiles = new Profiles()
|
||||
profiles.setName(null, 'trout')
|
||||
assert.equal(profiles.getName(null), null)
|
||||
})
|
||||
Reference in New Issue
Block a user