Skip to content

Commit

Permalink
[PLA-2055] Fix CreateFuelTankMutation on no dispatchRule (#75)
Browse files Browse the repository at this point in the history
Signed-off-by: Leonardo Custodio <leonardo@enjin.io>
  • Loading branch information
leonardocustodio authored Dec 4, 2024
1 parent f5728d4 commit 40b742c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/GraphQL/Mutations/CreateFuelTankMutation.php
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function resolve(

public static function addPermittedExtrinsics(string $encodedData, array $dispatchRules): string
{
if ($dispatchRules[0]->permittedExtrinsics === null) {
if (empty($dispatchRules) || $dispatchRules[0]->permittedExtrinsics === null) {
return $encodedData;
}

Expand All @@ -151,7 +151,7 @@ public static function getEncodableParams(...$params): array
'descriptor' => [
'name' => HexConverter::stringToHexPrefixed($name),
'userAccountManagement' => $userAccountManagement?->toEncodable(),
'coveragePolicy' => $coveragePolicy->value,
'coveragePolicy' => $coveragePolicy?->value ?? CoveragePolicy::FEES->value,
'ruleSets' => [
[
'rules' => $ruleSets->flatMap(fn ($ruleSet) => $ruleSet->toEncodable())->all(),
Expand Down
15 changes: 15 additions & 0 deletions tests/Feature/GraphQL/Mutations/CreateFuelTankTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@ public function test_it_can_create_fuel_tank(): void
);
}

public function test_it_can_create_fuel_tank_only_with_required_args(): void
{
$data = [
'name' => fake()->text(32),
];

$response = $this->graphql($this->method, $data);
$expectedData = TransactionSerializer::encode($this->method, CreateFuelTankMutation::getEncodableParams(...$data));

$this->assertEquals(
$expectedData,
$response['encodedData'],
);
}

public function test_it_can_create_fuel_tank_with_zero_values(): void
{
$response = $this->graphql($this->method, $data = $this->generateData(true, 0));
Expand Down

0 comments on commit 40b742c

Please sign in to comment.