code.vegaprotocol.io/vega@v0.79.0/core/execution/spot/market_asset_test.go (about)

     1  // Copyright (C) 2023 Gobalsky Labs Limited
     2  //
     3  // This program is free software: you can redistribute it and/or modify
     4  // it under the terms of the GNU Affero General Public License as
     5  // published by the Free Software Foundation, either version 3 of the
     6  // License, or (at your option) any later version.
     7  //
     8  // This program is distributed in the hope that it will be useful,
     9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    11  // GNU Affero General Public License for more details.
    12  //
    13  // You should have received a copy of the GNU Affero General Public License
    14  // along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15  
    16  package spot_test
    17  
    18  import (
    19  	"code.vegaprotocol.io/vega/core/assets"
    20  	"code.vegaprotocol.io/vega/core/assets/common"
    21  	"code.vegaprotocol.io/vega/core/types"
    22  )
    23  
    24  type isAssetStub struct {
    25  	ID            string
    26  	DecimalPlaces uint64
    27  	Status        types.AssetStatus
    28  }
    29  
    30  func NewAssetStub(id string, dp uint64) *assets.Asset {
    31  	return assets.NewAsset(&isAssetStub{
    32  		ID:            id,
    33  		DecimalPlaces: dp,
    34  		Status:        types.AssetStatusEnabled,
    35  	})
    36  }
    37  
    38  func (a isAssetStub) Type() *types.Asset {
    39  	return &types.Asset{
    40  		ID: a.ID,
    41  		Details: &types.AssetDetails{
    42  			Symbol:   a.ID,
    43  			Decimals: a.DecimalPlaces,
    44  		},
    45  		Status: a.Status,
    46  	}
    47  }
    48  
    49  func (isAssetStub) GetAssetClass() common.AssetClass {
    50  	return common.Builtin
    51  }
    52  
    53  func (isAssetStub) IsValid() bool {
    54  	return true
    55  }
    56  
    57  func (isAssetStub) Validate() error {
    58  	return nil
    59  }
    60  
    61  func (isAssetStub) SetValid()          {}
    62  func (isAssetStub) SetPendingListing() {}
    63  func (isAssetStub) SetRejected()       {}
    64  func (isAssetStub) SetEnabled()        {}
    65  
    66  func (a isAssetStub) String() string {
    67  	return a.ID
    68  }