Skip to content

Commit

Permalink
test: fix test errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Xiawpohr committed Sep 18, 2024
1 parent 7654d25 commit 4fed2c7
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,15 @@ export class RelayApiService {

const reputation = data[0] - data[1]

const { publicSignals, proof } = reputation < 0
? await userState.genProveReputationProof({
maxRep: 1,
})
: await userState.genProveReputationProof({
minRep: 0,
})

const { publicSignals, proof } =
reputation < 0
? await userState.genProveReputationProof({
maxRep: 1,
})
: await userState.genProveReputationProof({
minRep: 0,
})

const token = btoa(
JSON.stringify(stringifyBigInts({ publicSignals, proof })),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
},
},
getGuaranteedUserState: () => ({
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
waitForSync: jest.fn(),
latestTransitionedEpoch: jest.fn().mockResolvedValue(1),
genEpochKeyProof: jest.fn().mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
},
},
getGuaranteedUserState: () => ({
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
waitForSync: jest.fn(),
latestTransitionedEpoch: jest.fn().mockResolvedValue(1),
genEpochKeyProof: jest.fn().mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
},
},
getGuaranteedUserState: () => ({
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
waitForSync: jest.fn(),
latestTransitionedEpoch: jest.fn().mockResolvedValue(1),
genEpochKeyProof: jest.fn().mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
},
},
getGuaranteedUserState: () => ({
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
waitForSync: jest.fn(),
latestTransitionedEpoch: jest.fn().mockResolvedValue(1),
genEpochKeyProof: jest.fn().mockResolvedValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jest.mock('@/features/core/hooks/useRelayConfig/useRelayConfig', () => ({
jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
useUserState: () => ({
userState: {
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
getEpochKeys: jest
.fn()
.mockReturnValue(['epochKey-1', 'epochKey-2'].join(',')),
Expand All @@ -27,6 +28,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
},
},
getGuaranteedUserState: () => ({
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
getEpochKeys: jest
.fn()
.mockReturnValue(['epochKey-1', 'epochKey-2'].join(',')),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
id: {
secret: '0x123',
},
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
genProveReputationProof: jest.fn().mockResolvedValue({
publicSignals: 'mocked_signals',
proof: 'mocked_proof',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
id: {
secret: '0x123',
},
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
latestTransitionedEpoch: jest.fn().mockResolvedValue(2),
genProveReputationProof: jest.fn().mockResolvedValue({
publicSignals: 'mocked_signals',
Expand All @@ -39,6 +40,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
id: {
secret: '0x123',
},
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
latestTransitionedEpoch: jest.fn().mockResolvedValue(2),
genProveReputationProof: jest.fn().mockResolvedValue({
publicSignals: 'mocked_signals',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
id: {
secret: '0x123',
},
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
genProveReputationProof: jest.fn().mockResolvedValue({
publicSignals: 'mocked_signals',
proof: 'mocked_proof',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ jest.mock('@/features/core/hooks/useUserState/useUserState', () => ({
id: {
secret: '0x123',
},
getData: () => [BigInt(2), BigInt(1), BigInt(0), BigInt(0)],
genProveReputationProof: jest.fn().mockResolvedValue({
publicSignals: 'mocked_signals',
proof: 'mocked_proof',
Expand Down

0 comments on commit 4fed2c7

Please sign in to comment.