-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/feat/Create-ingredients' into fe…
…at/Create-ingredients
- Loading branch information
Showing
49 changed files
with
1,906 additions
and
241 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @hAMburg3rs/dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
addReviewers: true | ||
addAssignees: author | ||
|
||
reviewers: | ||
- upa-r-upa | ||
- kth1888 | ||
- Atralupus | ||
|
||
numberOfReviewers: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Backend build and test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- 'backend/app/**' | ||
tags: ["*"] | ||
pull_request: | ||
types: [ready_for_review, opened, reopened, auto_merge_enabled] | ||
|
||
jobs: | ||
build-and-tests: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
working-directory: 'backend/app/' | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Setup .NET Core | ||
uses: actions/setup-dotnet@v3 | ||
with: | ||
dotnet-version: 6.0.x | ||
|
||
- name: Install dependencies | ||
run: dotnet restore | ||
|
||
- name: Build and test | ||
run: | | ||
dotnet test --no-restore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace Savor22b.Tests.Action; | ||
|
||
using Libplanet; | ||
using Libplanet.Crypto; | ||
|
||
public class ActionTests | ||
{ | ||
private readonly PrivateKey _signer = new PrivateKey(); | ||
|
||
public ActionTests() | ||
{ | ||
} | ||
|
||
public PrivateKey Signer() | ||
{ | ||
return _signer; | ||
} | ||
|
||
public Address SignerAddress() | ||
{ | ||
return _signer.PublicKey.ToAddress(); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
backend/app/Savor22b.Tests/Action/BuyCookingEquipmentTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
namespace Savor22b.Tests.Action; | ||
|
||
using System; | ||
using Libplanet; | ||
using Libplanet.Assets; | ||
using Libplanet.Crypto; | ||
using Libplanet.State; | ||
using Savor22b.Action; | ||
using Savor22b.Constants; | ||
using Savor22b.States; | ||
using Xunit; | ||
|
||
public class BuyCookingEquipmentTests | ||
{ | ||
private PrivateKey _signer = new PrivateKey(); | ||
|
||
public BuyCookingEquipmentTests() | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void BuyCookingEquipmentExecute_AddsCookingEquipmentToKitchenStateList() | ||
{ | ||
IAccountStateDelta state = new DummyState(); | ||
state = state.MintAsset( | ||
_signer.PublicKey.ToAddress(), | ||
FungibleAssetValue.Parse( | ||
Currencies.KeyCurrency, | ||
"10" | ||
)); | ||
|
||
var random = new DummyRandom(1); | ||
var desiredEquipmentID = 1; | ||
|
||
var action = new BuyCookingEquipmentAction(Guid.NewGuid(), desiredEquipmentID); | ||
|
||
state = action.Execute(new DummyActionContext | ||
{ | ||
PreviousStates = state, | ||
Signer = _signer.PublicKey.ToAddress(), | ||
Random = random, | ||
Rehearsal = false, | ||
BlockIndex = 1, | ||
}); | ||
|
||
var rootStateEncoded = state.GetState(_signer.PublicKey.ToAddress()); | ||
RootState rootState = rootStateEncoded is Bencodex.Types.Dictionary bdict | ||
? new RootState(bdict) | ||
: throw new Exception(); | ||
InventoryState inventoryState = rootState.InventoryState; | ||
|
||
Assert.Equal(0, inventoryState.SeedStateList.Count); | ||
Assert.Equal(0, inventoryState.RefrigeratorStateList.Count); | ||
Assert.Equal(1, inventoryState.CookingEquipmentStateList.Count); | ||
Assert.Equal(desiredEquipmentID, inventoryState.CookingEquipmentStateList[0].CookingEquipmentID); | ||
Assert.Equal( | ||
FungibleAssetValue.Parse( | ||
Currencies.KeyCurrency, | ||
"0" | ||
), | ||
state.GetBalance(_signer.PublicKey.ToAddress(), Currencies.KeyCurrency)); | ||
Assert.Equal( | ||
FungibleAssetValue.Parse( | ||
Currencies.KeyCurrency, | ||
"10" | ||
), | ||
state.GetBalance(Addresses.ShopVaultAddress, Currencies.KeyCurrency)); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
backend/app/Savor22b.Tests/Action/BuyRandomSeedItemActionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
namespace Savor22b.Tests.Action; | ||
|
||
using System; | ||
using Libplanet; | ||
using Libplanet.Assets; | ||
using Libplanet.Crypto; | ||
using Libplanet.State; | ||
using Savor22b.Action; | ||
using Savor22b.Constants; | ||
using Savor22b.States; | ||
using Xunit; | ||
|
||
public class BuyRandomSeedItemActionTests : ActionTests | ||
{ | ||
|
||
public BuyRandomSeedItemActionTests() | ||
{ | ||
} | ||
|
||
[Fact] | ||
public void BuyRandomSeedItemActionExecute_AddsItemToItemStateList() | ||
{ | ||
IAccountStateDelta state = new DummyState(); | ||
state = state.MintAsset( | ||
SignerAddress(), | ||
FungibleAssetValue.Parse( | ||
Currencies.KeyCurrency, | ||
"10" | ||
)); | ||
|
||
var random = new DummyRandom(1); | ||
var desiredRandomSeedItemID = 1; | ||
|
||
var action = new BuyRandomSeedItemAction(Guid.NewGuid(), desiredRandomSeedItemID); | ||
|
||
state = action.Execute(new DummyActionContext | ||
{ | ||
PreviousStates = state, | ||
Signer = SignerAddress(), | ||
Random = random, | ||
Rehearsal = false, | ||
BlockIndex = 1, | ||
}); | ||
|
||
var inventoryStateEncoded = state.GetState(SignerAddress()); | ||
InventoryState inventoryState = | ||
inventoryStateEncoded is Bencodex.Types.Dictionary bdict | ||
? new InventoryState(bdict) | ||
: throw new Exception(); | ||
|
||
Assert.Equal(0, inventoryState.SeedStateList.Count); | ||
Assert.Equal(0, inventoryState.RefrigeratorStateList.Count); | ||
Assert.Equal(0, inventoryState.CookingEquipmentStateList.Count); | ||
Assert.Equal(1, inventoryState.ItemStateList.Count); | ||
Assert.Equal(desiredRandomSeedItemID, inventoryState.ItemStateList[0].ItemID); | ||
Assert.Equal( | ||
FungibleAssetValue.Parse( | ||
Currencies.KeyCurrency, | ||
"0" | ||
), | ||
state.GetBalance(SignerAddress(), Currencies.KeyCurrency)); | ||
Assert.Equal( | ||
FungibleAssetValue.Parse( | ||
Currencies.KeyCurrency, | ||
"10" | ||
), | ||
state.GetBalance(Addresses.ShopVaultAddress, Currencies.KeyCurrency)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 0 additions & 86 deletions
86
backend/app/Savor22b.Tests/Action/GenerateSeedActionTests.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.