Skip to content

Commit

Permalink
fix eclp input validation tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MattPereira committed Mar 5, 2025
1 parent e89d980 commit 21e841e
Showing 1 changed file with 21 additions and 45 deletions.
66 changes: 21 additions & 45 deletions test/v3/createPool/gyroECLP/gyroECLP.validation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,37 +169,33 @@ describe('create GyroECLP pool input validations', () => {
test('RotationVectorSWrong()', async () => {
expect(() =>
buildCallWithModifiedInput({ eclpParams: { s: -1n } }),
).toThrowError('RotationVectorSWrong: s must be >= 0');
).toThrowError('s must be >= 0 and <= 1000000000000000000');

expect(() =>
buildCallWithModifiedInput({
eclpParams: { s: _ONE + 1n },
}),
).toThrowError(`RotationVectorSWrong: s must be <= ${_ONE}`);
).toThrowError('s must be >= 0 and <= 1000000000000000000');
});

test('RotationVectorCWrong()', async () => {
expect(() =>
buildCallWithModifiedInput({ eclpParams: { c: -1n } }),
).toThrowError('RotationVectorCWrong: c must be >= 0');
).toThrowError('c must be >= 0 and <= 1000000000000000000');

expect(() =>
buildCallWithModifiedInput({
eclpParams: { c: _ONE + 1n },
}),
).toThrowError(`RotationVectorCWrong: c must be <= ${_ONE}`);
).toThrowError('c must be >= 0 and <= 1000000000000000000');
});

test('scnorm2 outside valid range', async () => {
expect(() =>
buildCallWithModifiedInput({
eclpParams: { s: 1n, c: 1n },
}),
).toThrowError(
`RotationVectorNotNormalized: scnorm2 must be >= ${
_ONE - _ROTATION_VECTOR_NORM_ACCURACY
}`,
);
).toThrowError('RotationVectorNotNormalized');

expect(() =>
buildCallWithModifiedInput({
Expand All @@ -208,26 +204,24 @@ describe('create GyroECLP pool input validations', () => {
c: parseUnits('1', 18),
},
}),
).toThrowError(
`RotationVectorNotNormalized: scnorm2 must be <= ${
_ONE + _ROTATION_VECTOR_NORM_ACCURACY
}`,
);
).toThrowError('RotationVectorNotNormalized');
});

test('lambda outside valid range', async () => {
expect(() =>
buildCallWithModifiedInput({
eclpParams: { lambda: -1n },
}),
).toThrowError('StretchingFactorWrong: lambda must be >= 0');
).toThrowError(
'lambda must be >= 0 and <= 100000000000000000000000000',
);

expect(() =>
buildCallWithModifiedInput({
eclpParams: { lambda: _MAX_STRETCH_FACTOR + 1n },
}),
).toThrowError(
`StretchingFactorWrong: lambda must be <= ${_MAX_STRETCH_FACTOR}`,
'lambda must be >= 0 and <= 100000000000000000000000000',
);
});
});
Expand All @@ -238,15 +232,15 @@ describe('create GyroECLP pool input validations', () => {
buildCallWithModifiedInput({
derivedEclpParams: { tauAlpha: { y: -1n } },
}),
).toThrowError('DerivedTauAlphaYWrong: tuaAlpha.y must be > 0');
).toThrowError('tuaAlpha.y must be > 0');
});

test('DerivedTauBetaYWrong()', async () => {
expect(() =>
buildCallWithModifiedInput({
derivedEclpParams: { tauBeta: { y: -1n } },
}),
).toThrowError('DerivedTauBetaYWrong: tauBeta.y must be > 0');
).toThrowError('tauBeta.y must be > 0');
});

test('DerivedTauXWrong()', async () => {
Expand All @@ -258,9 +252,7 @@ describe('create GyroECLP pool input validations', () => {
},
},
}),
).toThrowError(
'DerivedTauXWrong: derived.tauBeta.x must be > derived.tauAlpha.x',
);
).toThrowError('tauBeta.x must be > tauAlpha.x');
});

test('DerivedTauAlphaNotNormalized()', async () => {
Expand All @@ -273,11 +265,7 @@ describe('create GyroECLP pool input validations', () => {
},
},
}),
).toThrowError(
`DerivedTauBetaNotNormalized: norm2 must be >= ${
_ONE_XP - _DERIVED_TAU_NORM_ACCURACY_XP
}`,
);
).toThrowError('RotationVectorNotNormalized()');

expect(() =>
buildCallWithModifiedInput({
Expand All @@ -288,37 +276,33 @@ describe('create GyroECLP pool input validations', () => {
},
},
}),
).toThrowError(
`DerivedTauBetaNotNormalized: norm2 must be <= ${
_ONE_XP + _DERIVED_TAU_NORM_ACCURACY_XP
}`,
);
).toThrowError('RotationVectorNotNormalized()');
});

test('Derived parameters u, v, w, z limits', async () => {
expect(() =>
buildCallWithModifiedInput({
derivedEclpParams: { u: _ONE_XP + 1n },
}),
).toThrowError(`DerivedUWrong: u must be <= ${_ONE_XP}`);
).toThrowError(`u must be <= ${_ONE_XP}`);

expect(() =>
buildCallWithModifiedInput({
derivedEclpParams: { v: _ONE_XP + 1n },
}),
).toThrowError(`DerivedVWrong: v must be <= ${_ONE_XP}`);
).toThrowError(`v must be <= ${_ONE_XP}`);

expect(() =>
buildCallWithModifiedInput({
derivedEclpParams: { w: _ONE_XP + 1n },
}),
).toThrowError(`DerivedWWrong: w must be <= ${_ONE_XP}`);
).toThrowError(`w must be <= ${_ONE_XP}`);

expect(() =>
buildCallWithModifiedInput({
derivedEclpParams: { z: _ONE_XP + 1n },
}),
).toThrowError(`DerivedZWrong: z must be <= ${_ONE_XP}`);
).toThrowError(`z must be <= ${_ONE_XP}`);
});

test('DerivedDsqWrong()', async () => {
Expand All @@ -328,23 +312,15 @@ describe('create GyroECLP pool input validations', () => {
dSq: _ONE_XP - _DERIVED_DSQ_NORM_ACCURACY_XP - 1n,
},
}),
).toThrowError(
`DerivedDSqWrong: dSq must be >= ${
_ONE_XP - _DERIVED_DSQ_NORM_ACCURACY_XP
}`,
);
).toThrowError('DerivedDsqWrong()');

expect(() =>
buildCallWithModifiedInput({
derivedEclpParams: {
dSq: _ONE_XP + _DERIVED_DSQ_NORM_ACCURACY_XP + 1n,
},
}),
).toThrowError(
`DerivedDSqWrong: dSq must be <= ${
_ONE_XP + _DERIVED_DSQ_NORM_ACCURACY_XP
}`,
);
).toThrowError('DerivedDsqWrong()');
});

// TODO: grow bigger brain to figure out param values that trigger InvariantDenominatorWrong
Expand Down

0 comments on commit 21e841e

Please sign in to comment.