feat: redesign auction engine with redis sot
This commit is contained in:
1 parent
737702d78c
commit
e8bb20d988
75 files changed
+12737
-542
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import { buildAuctionRedisKeys } from './auction-redis.keys';
|
||||
import {
|
||||
AUCTION_RESERVE_ACTION_REQUEST_SCRIPT,
|
||||
buildActionRequestPayloadFingerprint,
|
||||
buildAuctionReserveActionRequestScriptInvocation,
|
||||
} from './auction-redis.reserve-action';
|
||||
|
||||
describe('auction reserve action request redis script contract', () => {
|
||||
it('builds RESERVE_AUCTION_ACTION_REQUEST keys and values', () => {
|
||||
const invocation = buildAuctionReserveActionRequestScriptInvocation(
|
||||
buildAuctionRedisKeys('match-1'),
|
||||
{
|
||||
auctionActionRequestId: 'request-1',
|
||||
auctionActionType: 'sold',
|
||||
auctionStateTransitionId: 'transition-1',
|
||||
clientObservedAuctionLifecycleId: 'life-1',
|
||||
clientObservedPhase: 'bidding',
|
||||
clientObservedRevision: 8,
|
||||
leaseDurationMS: 10_000,
|
||||
maximumStoredAuctionActionRequestResultCount: 100,
|
||||
minimumAuctionActionRequestResultReplayWindowMS: 60_000,
|
||||
newAuctionLifecycleId: undefined,
|
||||
processingOwnerToken: 'owner-1',
|
||||
},
|
||||
);
|
||||
|
||||
expect(invocation.script).toBe(AUCTION_RESERVE_ACTION_REQUEST_SCRIPT);
|
||||
expect(invocation.keys).toEqual([
|
||||
'auction:match-1:auctionActionRequestResults',
|
||||
'auction:match-1:auctionActionRequestResultOrder',
|
||||
]);
|
||||
expect(invocation.values).toEqual([
|
||||
'life-1',
|
||||
'request-1',
|
||||
'sold',
|
||||
'transition-1',
|
||||
'',
|
||||
'owner-1',
|
||||
'10000',
|
||||
'100',
|
||||
'60000',
|
||||
'life-1|request-1|sold|8|bidding||',
|
||||
]);
|
||||
});
|
||||
|
||||
it('builds stable action request fingerprints', () => {
|
||||
expect(
|
||||
buildActionRequestPayloadFingerprint({
|
||||
auctionActionRequestId: 'request-1',
|
||||
auctionActionType: 'next',
|
||||
clientObservedAuctionLifecycleId: 'life-1',
|
||||
clientObservedCurrentAuctionPlayerOrderIndex: 3,
|
||||
clientObservedCurrentBidRoundPlayerUserId: 'player-1',
|
||||
clientObservedPhase: 'sold',
|
||||
clientObservedRevision: 9,
|
||||
}),
|
||||
).toBe('life-1|request-1|next|9|sold|player-1|3');
|
||||
});
|
||||
|
||||
it('keeps lease version and replay guards in Lua', () => {
|
||||
expect(AUCTION_RESERVE_ACTION_REQUEST_SCRIPT.lua).toContain(
|
||||
"redis.call('TIME')",
|
||||
);
|
||||
expect(AUCTION_RESERVE_ACTION_REQUEST_SCRIPT.lua).toContain(
|
||||
'processingLeaseVersion',
|
||||
);
|
||||
expect(AUCTION_RESERVE_ACTION_REQUEST_SCRIPT.lua).toContain(
|
||||
'ACTION_REQUEST_IN_PROGRESS',
|
||||
);
|
||||
expect(AUCTION_RESERVE_ACTION_REQUEST_SCRIPT.lua).toContain(
|
||||
'ACTION_REQUEST_RESULT_LIMIT',
|
||||
);
|
||||
expect(AUCTION_RESERVE_ACTION_REQUEST_SCRIPT.lua).toContain(
|
||||
'DUPLICATE_ACTION_REQUEST_CONFLICT',
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user