mirror of
https://github.com/Mezeporta/Erupe.git
synced 2026-03-27 01:53:19 +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:
@@ -27,6 +27,7 @@ func TestGachaService_PlayNormalGacha(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "transact error",
|
||||
pool: []GachaEntry{{ID: 10, Weight: 100}},
|
||||
txErr: errors.New("tx fail"),
|
||||
wantErr: true,
|
||||
},
|
||||
@@ -36,6 +37,10 @@ func TestGachaService_PlayNormalGacha(t *testing.T) {
|
||||
poolErr: errors.New("pool fail"),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "empty reward pool",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "success single roll",
|
||||
txRolls: 1,
|
||||
@@ -95,6 +100,7 @@ func TestGachaService_PlayStepupGacha(t *testing.T) {
|
||||
}{
|
||||
{
|
||||
name: "transact error",
|
||||
pool: []GachaEntry{{ID: 10, Weight: 100}},
|
||||
txErr: errors.New("tx fail"),
|
||||
wantErr: true,
|
||||
},
|
||||
@@ -104,6 +110,10 @@ func TestGachaService_PlayStepupGacha(t *testing.T) {
|
||||
poolErr: errors.New("pool fail"),
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "empty reward pool",
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "success with guaranteed",
|
||||
txRolls: 1,
|
||||
|
||||
Reference in New Issue
Block a user