Skip to content

Commit ba1dc84

Browse files
committed
revert: not necessary to mock ens
1 parent d17fa5d commit ba1dc84

File tree

3 files changed

+2
-64
lines changed

3 files changed

+2
-64
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@ test-karma-webpack
1010
.plebbit
1111
.plebbit/
1212

13-
# test-server generated files
14-
test/test-server/ens-test-signer.json
15-
1613
# build folder
1714
dist/
1815
/dist/

test/browser-e2e/accounts.test.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,9 @@ import subplebbitsStore from '../../dist/stores/subplebbits'
88
import testUtils from '../../dist/lib/test-utils'
99
import {offlineIpfs, pubsubIpfs, plebbitRpc} from '../test-server/config'
1010
import signers from '../fixtures/signers'
11-
1211
const subplebbitAddress = signers[0].address
1312
const adminRoleSigner = signers[1]
1413

15-
// Load ENS test signer info from test-server via HTTP
16-
// This allows tests to create subplebbits with a signer that matches 'my-sub.eth'
17-
// The test-server has an endpoint at http://localhost:59281/ens-test-signer
18-
let ensTestSignerPromise
19-
const loadEnsTestSigner = async () => {
20-
const response = await fetch('http://localhost:59281/ens-test-signer')
21-
return await response.json()
22-
}
23-
ensTestSignerPromise = loadEnsTestSigner()
24-
2514
const isBase64 = (testString) => /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}))?$/gm.test(testString)
2615

2716
// large value for manual debugging
@@ -144,17 +133,7 @@ for (const plebbitOptionsType in plebbitOptionsTypes) {
144133
const createdSubplebbitTitle = 'my title'
145134
let subplebbit
146135
await act(async () => {
147-
// Use the ensTestSigner so that 'my-sub.eth' resolves to this subplebbit's address
148-
// This is required for the ENS address validation to pass
149-
const ensTestSigner = await ensTestSignerPromise
150-
const createOptions = {title: createdSubplebbitTitle}
151-
if (ensTestSigner) {
152-
createOptions.signer = {
153-
type: ensTestSigner.type,
154-
privateKey: ensTestSigner.privateKey,
155-
}
156-
}
157-
subplebbit = await rendered.result.current.createSubplebbit(createOptions)
136+
subplebbit = await rendered.result.current.createSubplebbit({title: createdSubplebbitTitle})
158137
})
159138
console.log('after create subplebbit', subplebbit.address)
160139
const createdSubplebbitAddress = subplebbit?.address

test/test-server/index.js

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ import startPlebbitRpc from './start-plebbit-rpc.js'
66
import signers from '../fixtures/signers.js'
77
import {directory as getTmpFolderPath} from 'tempy'
88
import http from 'http'
9-
import fs from 'fs'
10-
import path from 'path'
11-
import {fileURLToPath} from 'url'
12-
13-
const __filename = fileURLToPath(import.meta.url)
14-
const __dirname = path.dirname(__filename)
159
const plebbitDataPath = getTmpFolderPath()
1610

1711
// set up a subplebbit for testing
@@ -47,32 +41,6 @@ const plebbitDataPath = getTmpFolderPath()
4741
})
4842
const signer = await plebbit.createSigner({privateKey, type: 'ed25519'})
4943

50-
// Create a signer for testing ENS domain address editing
51-
// The 'my-sub.eth' domain should resolve to this signer's address
52-
const ensTestSigner = await plebbit.createSigner()
53-
const ensTestDomain = 'my-sub.eth'
54-
55-
// Mock the ENS text record for 'my-sub.eth' to point to ensTestSigner.address
56-
// This allows the test to successfully edit a subplebbit's address to 'my-sub.eth'
57-
const cacheKey = plebbit._clientsManager._getKeyOfCachedDomainTextRecord(ensTestDomain, 'subplebbit-address')
58-
const timestamp = () => Math.floor(Date.now() / 1000)
59-
await plebbit._storage.setItem(cacheKey, {
60-
timestampSeconds: timestamp(),
61-
valueOfTextRecord: ensTestSigner.address,
62-
})
63-
console.log(`Mocked ENS text record '${ensTestDomain}' -> '${ensTestSigner.address}'`)
64-
65-
// Export the ENS test signer info to a file so tests can use it
66-
const ensTestSignerInfo = {
67-
privateKey: ensTestSigner.privateKey,
68-
address: ensTestSigner.address,
69-
type: ensTestSigner.type,
70-
domain: ensTestDomain,
71-
}
72-
const signerInfoPath = path.join(__dirname, 'ens-test-signer.json')
73-
fs.writeFileSync(signerInfoPath, JSON.stringify(ensTestSignerInfo, null, 2))
74-
console.log(`Exported ENS test signer info to '${signerInfoPath}'`)
75-
7644
console.log(`creating subplebbit with address '${signer.address}'...`)
7745
const subplebbit = await plebbit.createSubplebbit({
7846
signer: signer,
@@ -114,13 +82,7 @@ const plebbitDataPath = getTmpFolderPath()
11482
http
11583
.createServer((req, res) => {
11684
res.setHeader('Access-Control-Allow-Origin', '*')
117-
if (req.url === '/ens-test-signer') {
118-
// Return the ENS test signer info for browser tests
119-
res.setHeader('Content-Type', 'application/json')
120-
res.end(JSON.stringify(ensTestSignerInfo))
121-
} else {
122-
res.end('test server ready')
123-
}
85+
res.end('test server ready')
12486
})
12587
.listen(59281)
12688
})

0 commit comments

Comments
 (0)