mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 10:03:06 +01:00
fix(gacha): validate reward pool before charging currency (#175)
Filter out gacha entries with no items at the query level (EXISTS subquery) and reorder Play methods to validate the pool before calling transact(), so players are never charged for a misconfigured gacha.
This commit is contained in:
@@ -186,7 +186,10 @@ func TestHandleMsgMhfReceiveGachaItem_Freeze(t *testing.T) {
|
||||
|
||||
func TestHandleMsgMhfPlayNormalGacha_TransactError(t *testing.T) {
|
||||
server := createMockServer()
|
||||
gachaRepo := &mockGachaRepo{txErr: errors.New("transact failed")}
|
||||
gachaRepo := &mockGachaRepo{
|
||||
txErr: errors.New("transact failed"),
|
||||
rewardPool: []GachaEntry{{ID: 10, Weight: 100}},
|
||||
}
|
||||
server.gachaRepo = gachaRepo
|
||||
server.userRepo = &mockUserRepoGacha{}
|
||||
ensureGachaService(server)
|
||||
@@ -269,7 +272,10 @@ func TestHandleMsgMhfPlayNormalGacha_Success(t *testing.T) {
|
||||
|
||||
func TestHandleMsgMhfPlayStepupGacha_TransactError(t *testing.T) {
|
||||
server := createMockServer()
|
||||
gachaRepo := &mockGachaRepo{txErr: errors.New("transact failed")}
|
||||
gachaRepo := &mockGachaRepo{
|
||||
txErr: errors.New("transact failed"),
|
||||
rewardPool: []GachaEntry{{ID: 10, Weight: 100}},
|
||||
}
|
||||
server.gachaRepo = gachaRepo
|
||||
server.userRepo = &mockUserRepoGacha{}
|
||||
ensureGachaService(server)
|
||||
@@ -473,7 +479,10 @@ func TestHandleMsgMhfGetBoxGachaInfo_Success(t *testing.T) {
|
||||
|
||||
func TestHandleMsgMhfPlayBoxGacha_TransactError(t *testing.T) {
|
||||
server := createMockServer()
|
||||
gachaRepo := &mockGachaRepo{txErr: errors.New("transact failed")}
|
||||
gachaRepo := &mockGachaRepo{
|
||||
txErr: errors.New("transact failed"),
|
||||
rewardPool: []GachaEntry{{ID: 10, Weight: 100}},
|
||||
}
|
||||
server.gachaRepo = gachaRepo
|
||||
server.userRepo = &mockUserRepoGacha{}
|
||||
ensureGachaService(server)
|
||||
|
||||
Reference in New Issue
Block a user