This commit is contained in:
Matt Hill
2021-10-11 11:15:12 -06:00
committed by Aiden McClelland
parent 36f0959bc2
commit e864d0eb64
22 changed files with 18665 additions and 1268 deletions

View File

@@ -458,7 +458,7 @@ export module Mock {
'config': null,
'critical': true,
},
'bitcoin-proxy': {
'btc-rpc-proxy': {
'version': '>=0.2.2',
'description': 'As long as Bitcoin is pruned, LND needs Bitcoin Proxy to fetch block over the P2P network.',
'requirement': {
@@ -472,7 +472,7 @@ export module Mock {
}
export const MockManifestBitcoinProxy: Manifest = {
id: 'bitcoin-proxy',
id: 'btc-rpc-proxy',
title: 'Bitcoin Proxy',
version: '0.2.2',
description: {
@@ -661,9 +661,9 @@ export module Mock {
title: 'Bitcoin Core',
icon: 'assets/img/service-icons/bitcoind.png',
},
'bitcoin-proxy': {
'btc-rpc-proxy': {
title: 'Bitcoin Proxy',
icon: 'assets/img/service-icons/bitcoin-proxy.png',
icon: 'assets/img/service-icons/btc-rpc-proxy.png',
},
},
},
@@ -683,9 +683,9 @@ export module Mock {
title: 'Bitcoin Core',
icon: 'assets/img/service-icons/bitcoind.png',
},
'bitcoin-proxy': {
'btc-rpc-proxy': {
title: 'Bitcoin Proxy',
icon: 'assets/img/service-icons/bitcoin-proxy.png',
icon: 'assets/img/service-icons/btc-rpc-proxy.png',
},
},
},
@@ -701,16 +701,16 @@ export module Mock {
title: 'Bitcoin Core',
icon: 'assets/img/service-icons/bitcoind.png',
},
'bitcoin-proxy': {
'btc-rpc-proxy': {
title: 'Bitcoin Proxy',
icon: 'assets/img/service-icons/bitcoin-proxy.png',
icon: 'assets/img/service-icons/btc-rpc-proxy.png',
},
},
},
},
'bitcoin-proxy': {
'btc-rpc-proxy': {
'latest': {
icon: 'assets/img/service-icons/bitcoin-proxy.png',
icon: 'assets/img/service-icons/btc-rpc-proxy.png',
license: 'licenseUrl',
instructions: 'instructionsUrl',
manifest: Mock.MockManifestBitcoinProxy,
@@ -1565,9 +1565,9 @@ export module Mock {
export const bitcoinProxy: PackageDataEntry = {
state: PackageState.Installed,
'static-files': {
'license': '/public/package-data/bitcoin-proxy/0.20.0/LICENSE.md',
'icon': '/assets/img/service-icons/bitcoin-proxy.png',
'instructions': '/public/package-data/bitcoin-proxy/0.20.0/INSTRUCTIONS.md',
'license': '/public/package-data/btc-rpc-proxy/0.20.0/LICENSE.md',
'icon': '/assets/img/service-icons/btc-rpc-proxy.png',
'instructions': '/public/package-data/btc-rpc-proxy/0.20.0/INSTRUCTIONS.md',
},
manifest: MockManifestBitcoinProxy,
installed: {
@@ -1629,7 +1629,7 @@ export module Mock {
status: PackageMainStatus.Stopped,
},
'dependency-errors': {
'bitcoin-proxy': {
'btc-rpc-proxy': {
type: DependencyErrorType.NotInstalled,
},
},
@@ -1652,7 +1652,7 @@ export module Mock {
pointers: [],
'health-checks': [],
},
'bitcoin-proxy': {
'btc-rpc-proxy': {
pointers: [],
'health-checks': [],
},
@@ -1662,9 +1662,9 @@ export module Mock {
manifest: Mock.MockManifestBitcoind,
icon: 'assets/img/service-icons/bitcoind.png',
},
'bitcoin-proxy': {
'btc-rpc-proxy': {
manifest: Mock.MockManifestBitcoinProxy,
icon: 'assets/img/service-icons/bitcoin-proxy.png',
icon: 'assets/img/service-icons/btc-rpc-proxy.png',
},
},
},
@@ -1673,7 +1673,7 @@ export module Mock {
export const LocalPkgs: { [key: string]: PackageDataEntry } = {
'bitcoind': bitcoind,
'bitcoin-proxy': bitcoinProxy,
'btc-rpc-proxy': bitcoinProxy,
'lnd': lnd,
}
}

View File

@@ -121,9 +121,6 @@ export module RR {
export type CreateBackupReq = WithExpire<{ logicalname: string, password: string }> // backup.create
export type CreateBackupRes = WithRevision<null>
export type RestoreBackupReq = { logicalname: string, password: string } // backup.restore - unauthed
export type RestoreBackupRes = null
// disk
export type GetDisksReq = { } // disk.list

View File

@@ -119,11 +119,6 @@ export abstract class ApiService implements Source<DataModel>, Http<DataModel> {
() => this.createBackupRaw(params),
)()
protected abstract restoreBackupRaw (params: RR.RestoreBackupReq): Promise<RR.RestoreBackupRes>
restoreBackup = (params: RR.RestoreBackupReq) => this.syncResponse(
() => this.restoreBackupRaw(params),
)()
// disk
abstract getDisks (params: RR.GetDisksReq): Promise<RR.GetDisksRes>

View File

@@ -191,10 +191,6 @@ export class LiveApiService extends ApiService {
return this.http.rpcRequest({ method: 'backup.create', params })
}
async restoreBackupRaw (params: RR.RestoreBackupReq): Promise <RR.RestoreBackupRes> {
return this.http.rpcRequest({ method: 'backup.restore', params })
}
// disk
getDisks (params: RR.GetDisksReq): Promise <RR.GetDisksRes> {

View File

@@ -282,11 +282,6 @@ export class MockApiService extends ApiService {
return res
}
async restoreBackupRaw (params: RR.RestoreBackupReq): Promise<RR.RestoreBackupRes> {
await pauseFor(2000)
return null
}
// disk
async getDisks (params: RR.GetDisksReq): Promise<RR.GetDisksRes> {
@@ -482,17 +477,27 @@ export class MockApiService extends ApiService {
value: PackageState.Removing,
},
]
const res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
setTimeout(async () => {
let res: any
try {
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
setTimeout(async () => {
const patch = [
{
op: PatchOp.REMOVE,
path: `/package-data/${params.id}`,
},
]
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
}, this.revertTime)
} catch (e) {
const patch = [
{
op: PatchOp.REMOVE,
path: `/package-data/${params.id}`,
path: `/recovered-packages/${params.id}`,
},
]
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
}, this.revertTime)
res = await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
}
return res
}
@@ -540,14 +545,32 @@ export class MockApiService extends ApiService {
if (i === initialProgress.size) {
initialProgress[phase.completion] = true
}
const patch = [
{
op: PatchOp.REPLACE,
path: `/package-data/${id}/install-progress`,
value: initialProgress,
},
]
await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
let patch: any
if (initialProgress['unpack-complete']) {
patch = [
{
op: PatchOp.REMOVE,
path: `/package-data/${id}/install-progress`,
},
{
op: PatchOp.REMOVE,
path: `/recovered-packages/${id}`,
},
]
} else {
patch = [
{
op: PatchOp.REPLACE,
path: `/package-data/${id}/install-progress`,
value: initialProgress,
},
]
}
try {
await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
} catch (e) {
console.error('Insufficient Mocks, happens when installing a service that does not exist in recovered-package')
}
}
}
@@ -592,12 +615,7 @@ export class MockApiService extends ApiService {
{
op: PatchOp.REPLACE,
path: '/server-info/status',
value: ServerStatus.Running,
},
{
op: PatchOp.REPLACE,
path: '/server-info/version',
value: '3.1.0',
value: ServerStatus.Updated,
},
{
op: PatchOp.REMOVE,
@@ -606,16 +624,16 @@ export class MockApiService extends ApiService {
]
await this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch } })
// quickly revert patch to proper version to prevent infinite refresh loop
// quickly revert server to "running" for continued testing
const patch2 = [
{
op: PatchOp.REPLACE,
path: '/server-info/version',
value: require('../../../../package.json').version,
path: '/server-info/status',
value: ServerStatus.Running,
},
]
this.http.rpcRequest<WithRevision<null>>({ method: 'db.patch', params: { patch: patch2 } })
}, 10000)
}, 1000)
}
}