-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update base gas price on solo (#722)
* feat: update base gas price on solo * minor update * fix: base gas price * add test and panic on error * refactor: resolve PR comments * update error message * add license header * fix: force pack block & update logs
- Loading branch information
1 parent
4fa7366
commit caf4f36
Showing
2 changed files
with
120 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Copyright (c) 2024 The VeChainThor developers | ||
|
||
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying | ||
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html> | ||
|
||
package solo | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/vechain/thor/v2/builtin" | ||
"github.com/vechain/thor/v2/chain" | ||
"github.com/vechain/thor/v2/genesis" | ||
"github.com/vechain/thor/v2/logdb" | ||
"github.com/vechain/thor/v2/muxdb" | ||
"github.com/vechain/thor/v2/state" | ||
"github.com/vechain/thor/v2/thor" | ||
"github.com/vechain/thor/v2/txpool" | ||
) | ||
|
||
func newSolo() *Solo { | ||
db := muxdb.NewMem() | ||
stater := state.NewStater(db) | ||
gene := genesis.NewDevnet() | ||
logDb, _ := logdb.NewMem() | ||
b, _, _, _ := gene.Build(stater) | ||
repo, _ := chain.NewRepository(db, b) | ||
mempool := txpool.New(repo, stater, txpool.Options{Limit: 10000, LimitPerAccount: 16, MaxLifetime: 10 * time.Minute}) | ||
|
||
return New(repo, stater, logDb, mempool, 0, true, false, thor.ForkConfig{}) | ||
} | ||
|
||
func TestInitSolo(t *testing.T) { | ||
solo := newSolo() | ||
|
||
// init solo -> this should mine a block with the gas price tx | ||
err := solo.init() | ||
assert.Nil(t, err) | ||
|
||
// check the gas price | ||
best := solo.repo.BestBlockSummary() | ||
newState := solo.stater.NewState(best.Header.StateRoot(), best.Header.Number(), best.Conflicts, best.SteadyNum) | ||
currentBGP, err := builtin.Params.Native(newState).Get(thor.KeyBaseGasPrice) | ||
assert.Nil(t, err) | ||
assert.Equal(t, baseGasPrice, currentBGP) | ||
} |