Skip to content

Commit

Permalink
[PLA-1506] Validate beam code exists. (#60)
Browse files Browse the repository at this point in the history
  • Loading branch information
v16Studios authored Dec 13, 2023
1 parent db82c1a commit 737bdab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GraphQL/Queries/GetPendingClaimsQuery.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function resolve(
protected function rules(array $args = []): array
{
return [
'code' => ['filled', 'max:1024'],
'code' => ['filled', 'max:1024', 'exists:beams,code,deleted_at,NULL'],
'account' => ['filled', new ValidSubstrateAccount()],
];
}
Expand Down
9 changes: 9 additions & 0 deletions tests/Feature/GraphQL/Queries/GetPendingClaimsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,16 @@ public function test_will_fail_with_invalid_parameters(): void
'account' => fake()->text(),
], true);
$this->assertArraySubset([
'code' => ['The selected code is invalid.'],
'account' => ['The account is not a valid substrate account.'],
], $response['error']);

$response = $this->graphql($this->method, [
'code' => fake()->realTextBetween(1025, 1032),
'account' => $this->claims->first()->wallet_public_key,
], true);
$this->assertArraySubset([
'code' => ['The code field must not be greater than 1024 characters.'],
], $response['error']);
}
}

0 comments on commit 737bdab

Please sign in to comment.