Skip to content

Commit

Permalink
Merge pull request #423 from xmtp/ar/remove-ethers-test
Browse files Browse the repository at this point in the history
Removed ethers from test
  • Loading branch information
alexrisch authored Jun 18, 2024
2 parents ea2ef84 + 3129752 commit 5852319
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions example/src/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { sha256 } from '@noble/hashes/sha256'
import { FramesClient } from '@xmtp/frames-client'
import { content, invitation, signature as signatureProto } from '@xmtp/proto'
import { createHmac } from 'crypto'
import { ethers } from 'ethers'
import ReactNativeBlobUtil from 'react-native-blob-util'
import Config from 'react-native-config'
import { TextEncoder, TextDecoder } from 'text-encoding'
Expand Down Expand Up @@ -1678,13 +1677,31 @@ test('can handle complex streaming setup with messages from self', async () => {
return true
})

class ViemSigner {
account: PrivateKeyAccount

constructor(account: PrivateKeyAccount) {
this.account = account
}

async getAddress() {
return this.account.address
}

async signMessage(message: string) {
return this.account.signMessage({ message })
}
}

test('can send and receive consent proofs', async () => {
const alixWallet = await ethers.Wallet.createRandom()
const boWallet = await ethers.Wallet.createRandom()
const bo = await Client.create(boWallet, { env: 'local' })
await delayToPropogate()
const alix = await Client.create(alixWallet, { env: 'local' })
await delayToPropogate()
const alixPrivateKey = generatePrivateKey()
const alixAccount = privateKeyToAccount(alixPrivateKey)
const boPrivateKey = generatePrivateKey()
const boAccount = privateKeyToAccount(boPrivateKey)
const alixSigner = new ViemSigner(alixAccount)
const boSigner = new ViemSigner(boAccount)
const alix = await Client.create(alixSigner, { env: 'local' })
const bo = await Client.create(boSigner, { env: 'local' })

const timestamp = Date.now()
const consentMessage =
Expand All @@ -1694,7 +1711,7 @@ test('can send and receive consent proofs', async () => {
`From Address: ${bo.address}\n` +
'\n' +
'For more info: https://xmtp.org/signatures/'
const sig = await alixWallet.signMessage(consentMessage)
const sig = await alixSigner.signMessage(consentMessage)
const consentProof = invitation.ConsentProofPayload.fromPartial({
payloadVersion:
invitation.ConsentProofPayloadVersion.CONSENT_PROOF_PAYLOAD_VERSION_1,
Expand Down

0 comments on commit 5852319

Please sign in to comment.