Skip to content

Commit

Permalink
extending
Browse files Browse the repository at this point in the history
  • Loading branch information
muku314115 committed Nov 6, 2023
1 parent eda4dfb commit 4f84495
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 28 deletions.
39 changes: 21 additions & 18 deletions x/launch/keeper/msg_edit_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,39 @@ func TestMsgEditChain(t *testing.T) {
)

// Create coordinators
_, coordAddress := ts.CreateCoordinator(ctx, r)
_, coordAddress2 := ts.CreateCoordinator(ctx, r)
_, coordAddr := ts.CreateCoordinator(ctx, r)
_, coordAddr2 := ts.CreateCoordinator(ctx, r)

coordAddress := coordAddr.String()
coordAddress2 := coordAddr2.String()

// Create a chain
launchID := ts.CreateChain(ctx, r, coordAddress.String(), "", false, 0)
launchID := ts.CreateChain(ctx, r, coordAddress, "", false, 0)

// create a project
projectID := ts.CreateProject(ctx, r, coordAddress.String())
projectID := ts.CreateProject(ctx, r, coordAddress)

// create a chain with an existing project
launchIDHasProject := ts.CreateChain(ctx, r, coordAddress.String(), "", true, projectID)
launchIDHasProject := ts.CreateChain(ctx, r, coordAddress, "", true, projectID)

// create a project
validProjectID := ts.CreateProject(ctx, r, coordAddress.String())
validProjectID := ts.CreateProject(ctx, r, coordAddress)

// create a project from a different address
projectDifferentCoordinator := ts.CreateProject(ctx, r, coordAddress2.String())
projectDifferentCoordinator := ts.CreateProject(ctx, r, coordAddress2)

// Create a new chain for more tests
launchID2 := ts.CreateChain(ctx, r, coordAddress.String(), "", false, 0)
launchID2 := ts.CreateChain(ctx, r, coordAddress, "", false, 0)

// create a new project and add a chainProjects entry to it
projectDuplicateChain := ts.CreateProject(ctx, r, coordAddress.String())
projectDuplicateChain := ts.CreateProject(ctx, r, coordAddress)

err := tk.ProjectKeeper.AddChainToProject(sdkCtx, projectDuplicateChain, launchID2)
require.NoError(t, err)

// create message with an invalid metadata length
msgEditChainInvalidMetadata := sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchID,
true,
validProjectID,
Expand All @@ -70,7 +73,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should allow setting a project ID",
msg: sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchID,
true,
validProjectID,
Expand All @@ -80,7 +83,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should allow editing metadata",
msg: sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchID,
false,
0,
Expand All @@ -90,7 +93,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should prevent editing chain from non existent launch id",
msg: sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchIDNoExist,
true,
0,
Expand All @@ -112,7 +115,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should prevent editing chain with invalid coordinator",
msg: sample.MsgEditChain(r,
coordAddress2.String(),
coordAddress2,
launchID,
true,
0,
Expand All @@ -123,7 +126,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should prevent setting project id for chain with a project",
msg: sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchIDHasProject,
true,
0,
Expand All @@ -134,7 +137,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should prevent setting project id where project does not exist",
msg: sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchID2,
true,
999,
Expand All @@ -145,7 +148,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should prevent setting project id where project has a different coordinator",
msg: sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchID2,
true,
projectDifferentCoordinator,
Expand All @@ -156,7 +159,7 @@ func TestMsgEditChain(t *testing.T) {
{
name: "should prevent setting project id where project chain entry is duplicated",
msg: sample.MsgEditChain(r,
coordAddress.String(),
coordAddress,
launchID2,
true,
projectDuplicateChain,
Expand Down
14 changes: 4 additions & 10 deletions x/launch/keeper/msg_update_launch_information_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,15 @@ import (
func TestMsgUpdateLaunchInformation(t *testing.T) {
sdkCtx, tk, ts := testkeeper.NewTestSetup(t)
ctx := sdk.WrapSDKContext(sdkCtx)
coordAddress := sample.Address(r)
coordAddress2 := sample.Address(r)
coordNoExist := sample.Address(r)
launchIDNoExist := uint64(1000)

// Create coordinators
msgCreateCoordinator := sample.MsgCreateCoordinator(coordAddress)
resCoord, err := ts.ProfileSrv.CreateCoordinator(ctx, &msgCreateCoordinator)
require.NoError(t, err)
coordID, coordAddr := ts.CreateCoordinator(ctx, r)
coordAddress := coordAddr.String()

coordID := resCoord.CoordinatorID

msgCreateCoordinator = sample.MsgCreateCoordinator(coordAddress2)
_, err = ts.ProfileSrv.CreateCoordinator(ctx, &msgCreateCoordinator)
require.NoError(t, err)
_, coordAddr2 := ts.CreateCoordinator(ctx, r)
coordAddress2 := coordAddr2.String()

// Create a chain
launchID := uint64(1)
Expand Down

0 comments on commit 4f84495

Please sign in to comment.