Skip to content

Commit

Permalink
fix sdk-kit e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
wow-sven committed Dec 20, 2024
1 parent 4a7bbb2 commit f0c71ae
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 34 deletions.
30 changes: 3 additions & 27 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion sdk/typescript/rooch-sdk-kit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@
"react-dom": "^18.3.1",
"size-limit": "^11.1.5",
"typescript": "^5.6.2",
"vite": "^5.4.4"
"vite": "^5.4.4",
"vitest": "2.1.0"
},
"dependencies": {
"@roochnetwork/rooch-sdk": "workspace:*",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
useConnectWallet,
useCreateSessionKey,
useCurrentSession,
useSession,
useSessions,
} from '../../src/index.js'

describe('useDefaultClient', () => {
Expand All @@ -38,7 +38,7 @@ describe('useDefaultClient', () => {
function useTestHook() {
const { mutateAsync: connectWallet } = useConnectWallet()
const { mutateAsync: createSessionKey } = useCreateSessionKey()
const sessions = useSession()
const sessions = useSessions()
const currentSession = useCurrentSession()
const networks = { test: { url: 'http://localhost:6767' } }
const defaultClient = useDefaultClient({ currentNetwork: 'test', networks })
Expand Down
23 changes: 19 additions & 4 deletions sdk/typescript/rooch-sdk-kit/test/mocks/mock-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
import { SupportChain } from '../../src/feature/index.js'
import { Wallet } from '../../src/wellet/wallet.js'
import { Mock, vi } from 'vitest'
import { WalletNetworkType } from '../../src/index.js'

export class MockBitcoinWallet extends Wallet {
private kp: Keypair
Expand Down Expand Up @@ -55,8 +56,8 @@ export class MockBitcoinWallet extends Wallet {
return 'mock'
}

getNetwork(): string {
return 'testnet'
getNetwork(): Promise<WalletNetworkType> {
return Promise.resolve('testnet')
}

getPublicKey(): PublicKey<Address> {
Expand All @@ -67,7 +68,7 @@ export class MockBitcoinWallet extends Wallet {
return this.kp.getRoochAddress()
}

getSupportNetworks(): string[] {
getSupportNetworks(): WalletNetworkType[] {
return ['testnet', 'livenet']
}

Expand Down Expand Up @@ -98,7 +99,9 @@ export class MockBitcoinWallet extends Wallet {

switchAccount(_: string): void {}

switchNetwork(_: string): void {}
switchNetwork(_: string): Promise<void> {
return Promise.resolve()
}

getDescription(): string {
return ''
Expand All @@ -111,4 +114,16 @@ export class MockBitcoinWallet extends Wallet {
getInstallUrl(): string {
return ''
}

sendBtc(input: {
toAddress: string
satoshis: number
options?: { feeRate: number }
}): Promise<string> {
throw new Error('Method not implemented.')
}

getBalance(): Promise<{ confirmed: number; unconfirmed: number; total: string }> {
throw new Error('Method not implemented.')
}
}

0 comments on commit f0c71ae

Please sign in to comment.