Skip to content

Commit

Permalink
vnft test helper
Browse files Browse the repository at this point in the history
  • Loading branch information
Allyson-English committed Apr 9, 2024
1 parent 10aa17d commit 55bd0cb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions internal/controllers/synthetic_devices_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (s *SyntheticDevicesControllerTestSuite) TestGetSyntheticDeviceMintingPaylo
test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Explorer", 2022, nil)

udID := ksuid.New().String()
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, s.pdb)
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, 57, s.pdb)
test.SetupCreateUserDeviceAPIIntegration(s.T(), "", "xddL", udID, integration.Id, s.pdb)

request := test.BuildRequest("GET", fmt.Sprintf("/v1/user/devices/%s/integrations/%s/commands/mint", udID, integration.Id), "")
Expand Down Expand Up @@ -163,7 +163,7 @@ func (s *SyntheticDevicesControllerTestSuite) TestGetSyntheticDeviceMintingPaylo
test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Explorer", 2022, nil)

udID := ksuid.New().String()
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, s.pdb)
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, 57, s.pdb)
test.SetupCreateUserDeviceAPIIntegration(s.T(), "", "xddL", udID, integration.Id, s.pdb)

request := test.BuildRequest("GET", fmt.Sprintf("/v1/user/devices/%s/integrations/%s/commands/mint", udID, integration.Id), "")
Expand All @@ -190,7 +190,7 @@ func (s *SyntheticDevicesControllerTestSuite) TestGetSyntheticDeviceMintingPaylo
test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Explorer", 2022, nil)

udID := ksuid.New().String()
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, s.pdb)
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, 57, s.pdb)
test.SetupCreateUserDeviceAPIIntegration(s.T(), "", "xddL", udID, integration.Id, s.pdb)

request := test.BuildRequest("GET", fmt.Sprintf("/v1/user/devices/%s/integrations/%s/commands/mint", udID, integration.Id), "")
Expand Down Expand Up @@ -219,7 +219,7 @@ func (s *SyntheticDevicesControllerTestSuite) TestGetSyntheticDeviceMintingPaylo
test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Explorer", 2022, nil)

udID := ksuid.New().String()
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, s.pdb)
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, 57, s.pdb)
test.SetupCreateUserDeviceAPIIntegration(s.T(), "", "xddL", udID, integration.Id, s.pdb)

request := test.BuildRequest("GET", fmt.Sprintf("/v1/user/devices/%s/integrations/%s/commands/mint", udID, integration.Id), "")
Expand Down Expand Up @@ -276,7 +276,7 @@ func (s *SyntheticDevicesControllerTestSuite) Test_MintSyntheticDeviceSmartcar()
test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Explorer", 2022, nil)

udID := ksuid.New().String()
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, s.pdb)
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, 57, s.pdb)
test.SetupCreateUserDeviceAPIIntegration(s.T(), "", "xddL", udID, integration.Id, s.pdb)

vehicleSig := common.BytesToHash(common.HexToAddress("20").Bytes()).Bytes()
Expand Down Expand Up @@ -379,7 +379,7 @@ func (s *SyntheticDevicesControllerTestSuite) TestSignSyntheticDeviceMintingPayl
test.BuildDeviceDefinitionGRPC(ksuid.New().String(), "Ford", "Explorer", 2022, nil)

udID := ksuid.New().String()
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, s.pdb)
test.SetupCreateVehicleNFTForMiddleware(s.T(), *addr, mockUserID, udID, 57, s.pdb)
test.SetupCreateUserDeviceAPIIntegration(s.T(), "", "xddL", udID, integration.Id, s.pdb)

req := `{
Expand Down
3 changes: 2 additions & 1 deletion internal/test/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ func SetupCreateVehicleNFT(t *testing.T, userDevice models.UserDevice, tokenID *
return &userDevice
}

func SetupCreateVehicleNFTForMiddleware(t *testing.T, addr common.Address, userID, userDeviceID string, pdb db.Store) *models.UserDevice {
func SetupCreateVehicleNFTForMiddleware(t *testing.T, addr common.Address, userID, userDeviceID string, tokenID int64, pdb db.Store) *models.UserDevice {
mint := models.MetaTransactionRequest{
ID: ksuid.New().String(),
}
Expand All @@ -326,6 +326,7 @@ func SetupCreateVehicleNFTForMiddleware(t *testing.T, addr common.Address, userI
MintRequestID: null.StringFrom(mint.ID),
OwnerAddress: null.BytesFrom(common.FromHex(addr.String())),
VinConfirmed: true,
TokenID: types.NewNullDecimal(new(decimal.Big).SetBigMantScale(big.NewInt(tokenID), 0)),
}
err = ud.Insert(context.Background(), pdb.DBS().Writer, boil.Infer())
assert.NoError(t, err)
Expand Down

0 comments on commit 55bd0cb

Please sign in to comment.