Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: added new test suite for PrngSystemContract (#416) #417

Merged
merged 4 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ jobs:
with:
testfilter: ShanghaiOpcodes

PrngSystemContract:
name: PrngSystemContract Test Suite
uses: ./.github/workflows/test-workflow.yml
with:
testfilter: PrngSystemContract

PublishResults:
name: Publish Results
if: ${{ !cancelled() }}
Expand Down
2 changes: 2 additions & 0 deletions test/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const Events = {
GetNonFungibleTokenInfo: 'GetNonFungibleTokenInfo',
TinyBars: 'TinyBars',
TinyCents: 'TinyCents',
PseudoRandomSeed: 'PseudoRandomSeed',
}

const Path = {
Expand Down Expand Up @@ -97,6 +98,7 @@ const Contract = {
ERC20SnapshotMock: 'ERC20SnapshotMock',
HRCContract: 'HRCContract',
ExchangeRateMock: 'ExchangeRateMock',
PrngSystemContract: 'PrngSystemContract',
}

const CALL_EXCEPTION = 'CALL_EXCEPTION'
Expand Down
46 changes: 46 additions & 0 deletions test/util-precompile/PrngSystemContract.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*-
*
* Hedera Smart Contracts
*
* Copyright (C) 2023 Hedera Hashgraph, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

const { expect } = require('chai')
const { ethers } = require('hardhat')
const Constants = require('../constants')

describe('PrngSystemContract tests', function () {
let prngSystemContract

before(async function () {
const factory = await ethers.getContractFactory(
Constants.Contract.PrngSystemContract
)

prngSystemContract = await factory.deploy()
})

it('should be able to execute getPseudorandomSeed to generate a pseudo random seed', async function () {
const tx = await prngSystemContract.getPseudorandomSeed()
const txReceipt = await tx.wait()

const result = txReceipt.events.filter(
(e) => e.event === Constants.Events.PseudoRandomSeed
)[0].args[0]

expect(result).to.exist
Nana-EC marked this conversation as resolved.
Show resolved Hide resolved
})
})
Loading