TESTNitroAdjudicator.sol

View Source: contracts/test/TESTNitroAdjudicator.sol

โ†— Extends: NitroAdjudicator

This contract extends the NitroAdjudicator contract to enable it to be more easily unit-tested. It exposes public or external functions that set storage variables or wrap otherwise internal functions. It should not be deployed in a production environment.


Functions


isAddressInArray

Wrapper for otherwise internal function. Tests whether a given address is in a given array of addresses.

function isAddressInArray(address suspect, address[] addresses) public pure
returns(bool)

Returns

true if the address is in the array, false otherwise

Arguments

NameTypeDescription
suspectaddressA single address of interest.
addressesaddress[]A line-up of possible perpetrators.

validSignatures

Wrapper for otherwise internal function. Given an array of state hashes, checks the validity of the supplied signatures. Valid means there is a signature for each participant, either on the hash of the state for which they are a mover, or on the hash of a state that appears after that state in the array.

function validSignatures(uint48 largestTurnNum, address[] participants, bytes32[] stateHashes, struct IForceMove.Signature[] sigs, uint8[] whoSignedWhat) public pure
returns(bool)

Returns

true if the signatures are valid, false otherwise

Arguments

NameTypeDescription
largestTurnNumuint48The largest turn number of the submitted states; will overwrite the stored value of turnNumRecord.
participantsaddress[]A list of addresses representing the participants of a channel.
stateHashesbytes32[]Array of keccak256(State) submitted in support of a state,
sigsstruct IForceMove.Signature[]Array of Signatures, one for each participant
whoSignedWhatuint8[]participant[i] signed stateHashes[whoSignedWhat[i]]

acceptableWhoSignedWhat

Wrapper for otherwise internal function. Given a declaration of which state in the support proof was signed by which participant, check if this declaration is acceptable. Acceptable means there is a signature for each participant, either on the hash of the state for which they are a mover, or on the hash of a state that appears after that state in the array.

function acceptableWhoSignedWhat(uint8[] whoSignedWhat, uint48 largestTurnNum, uint256 nParticipants, uint256 nStates) public pure
returns(bool)

Returns

true if whoSignedWhat is acceptable, false otherwise

Arguments

NameTypeDescription
whoSignedWhatuint8[]participant[i] signed stateHashes[whoSignedWhat[i]]
largestTurnNumuint48Largest turnNum of the support proof
nParticipantsuint256Number of participants in the channel
nStatesuint256Number of states in the support proof

recoverSigner

Wrapper for otherwise internal function. Given a digest and digital signature, recover the signer

function recoverSigner(bytes32 _d, struct IForceMove.Signature sig) public pure
returns(address)

Returns

signer

Arguments

NameTypeDescription
_dbytes32message digest
sigstruct IForceMove.Signatureethereum digital signature

setChannelStorage

Manually set the channelStorageHashes for a given channelId. Shortcuts the public methods (ONLY USE IN A TESTING ENVIRONMENT).

function setChannelStorage(bytes32 channelId, struct IForceMove.ChannelData channelData) public nonpayable

Arguments

NameTypeDescription
channelIdbytes32Unique identifier for a state channel.
channelDatastruct IForceMove.ChannelDataThe channelData to be hashed and stored against the channelId

setChannelStorageHash

Manually set the channelStorageHash for a given channelId. Shortcuts the public methods (ONLY USE IN A TESTING ENVIRONMENT).

function setChannelStorageHash(bytes32 channelId, bytes32 h) public nonpayable

Arguments

NameTypeDescription
channelIdbytes32Unique identifier for a state channel.
hbytes32The channelStorageHash to store against the channelId
Last updated on by geoknee